Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
boxhock committed Apr 23, 2021
1 parent 92610ff commit 95a88f2
Show file tree
Hide file tree
Showing 5 changed files with 627 additions and 6 deletions.
54 changes: 54 additions & 0 deletions blockchain/ethereum/eth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package ethereum

import (
"testing"

"github.com/smartcontractkit/external-initiator/store"

"github.com/stretchr/testify/require"
)

func Test_createManager(t *testing.T) {
rpcSub := store.Subscription{Job: "1234-rpc", Endpoint: store.Endpoint{Url: "https://example.com"}}
rpcManager, err := createManager(rpcSub)
require.NoError(t, err)

type args struct {
sub store.Subscription
}
tests := []struct {
name string
args args
want *manager
wantErr bool
}{
{
"creates manager with RPC subscriber",
args{rpcSub},
rpcManager,
false,
},
{
"fails with invalid URL scheme",
args{store.Subscription{Job: "1234-invalid-url", Endpoint: store.Endpoint{Url: "not valid"}}},
nil,
true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := createManager(tt.args.sub)
if (err != nil) != tt.wantErr {
t.Errorf("createManager() error = %v, wantErr %v", err, tt.wantErr)
return
}
if tt.want != nil && got == nil {
t.Errorf("createManager() got nil")
return
}
if got != nil && tt.want.subscriber.Type() != got.subscriber.Type() {
t.Errorf("createManager() got Type() = %v, want %v", got.subscriber.Type(), tt.want.subscriber.Type())
}
})
}
}
2 changes: 1 addition & 1 deletion blockchain/ethereum/runlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func parseBlockNumberResult(data []byte) (uint64, error) {
return strconv.ParseUint(str, 0, 64)
}

func (rm runlogManager) getFilterQuery(fromBlock string) (interface{}, error) {
func (rm runlogManager) getFilterQuery(fromBlock string) (map[string]interface{}, error) {
fq := *rm.fq

if fromBlock != "" {
Expand Down
Loading

0 comments on commit 95a88f2

Please sign in to comment.