Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions config/streamr.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"environment": "polygon",
"logLevel": "debug",
"contracts": {
"streamRegistryChainRPCs": {
"chainId": 137,
"rpcs": [{
"url": "https://rpc.ankr.com/polygon",
"timeout": 120000
}]
}
"ethereumNetwork": {
"chainId": 137
},
"rpcs": [{
"url": "https://rpc.ankr.com/polygon",
"timeout": 120000
}]
}
},
"plugins": {
Expand Down
87 changes: 87 additions & 0 deletions extensions/listener/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,90 @@ func Test_ParseEvent(t *testing.T) {
})
}
}

func TestSetConfig(t *testing.T) {
type testcase struct {
name string
data map[string]string
errorMessage string
wantErr bool
}

tests := []testcase{
{
name: "valid",
data: map[string]string{
"node": "ws://example.com",
"api_key": "",
"max_reconnects": "5",
"stream": "test_stream",
"target_db": "0x1A58f48A0369656015D6BE305a3716F84F979A86:dimo_weather",
"target_procedure": "procedure_name",
"input_mappings": "param1:key1,param2:key2.key2.1",
},
wantErr: false,
},
{
name: "invalid data_type for max_reconnects",
data: map[string]string{
"node": "ws://example.com",
"api_key": "",
"max_reconnects": "x",
"stream": "test_stream",
"target_db": "0x1A58f48A0369656015D6BE305a3716F84F979A86:dimo_weather",
"target_procedure": "procedure_name",
"input_mappings": "param1:key1,param2:key2.key2.1",
},
wantErr: true,
errorMessage: "invalid max_reconnects config: strconv.ParseInt: parsing \"x\": invalid syntax",
},
{
name: "invalid structure for target_db",
data: map[string]string{
"node": "ws://example.com",
"api_key": "",
"max_reconnects": "5",
"stream": "nnn",
"target_db": "deployer_address:db_name",
"target_procedure": "procedure_name",
"input_mappings": "param1:key1,param2:key2.key2.1",
},
wantErr: true,
errorMessage: "invalid deployer address in target_db config: encoding/hex: invalid byte: U+0070 'p'",
},
{
name: "invalid structure for target_db",
data: map[string]string{
"node": "ws://example.com",
"api_key": "",
"max_reconnects": "5",
"stream": "nnn",
"target_db": "0x1A58f48A0369656015D6BE305a3716F84F979A86:db_name",
"target_procedure": "procedure_name",
"input_mappings": "param1,key11,",
},
wantErr: true,
errorMessage: "invalid input mapping: param1",
},
{
name: "invalid prop",
data: map[string]string{
"api_key": "12345",
},
errorMessage: "missing required Streamr node URL config",
wantErr: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := (&listenerConfig{}).setConfig(tt.data)
if tt.wantErr {
require.Error(t, err)
require.Equal(t, tt.errorMessage, err.Error())
return
}
require.Nil(t, err)
})
}
}
29 changes: 29 additions & 0 deletions extensions/resolution/resolution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,32 @@ func Test_ParamMatching(t *testing.T) {
})
}
}


func Test_TxID(t *testing.T) {
tests := []struct {
name string
event StreamrEvent
expected string
}{
{
name: "Valid Input",
event: StreamrEvent{
Values: nil,
TargetDBID: "",
TargetProcedure: "",
Timestamp: 1630000000, // Example timestamp
SequenceID: 100, // Example sequence ID
MsgChainID: "12345", // Example MsgChainID
},
expected: "80d327610000000064000000000000003132333435e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := tt.event.TxID()
require.Equal(t, tt.expected, result, "TxID should match expected value")
})
}
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21.0
require (
github.com/gorilla/websocket v1.5.2
github.com/jpillora/backoff v1.0.0
github.com/kwilteam/kwil-db v0.8.1
github.com/kwilteam/kwil-db v0.8.4
github.com/kwilteam/kwil-db/core v0.2.1
github.com/stretchr/testify v1.9.0
)
Expand Down Expand Up @@ -77,7 +77,7 @@ require (
github.com/klauspost/compress v1.17.8 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kwilteam/kwil-db/parse v0.2.1 // indirect
github.com/kwilteam/kwil-db/parse v0.2.4 // indirect
github.com/kwilteam/kwil-extensions v0.0.0-20230727040522-1cfd930226b7 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,14 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kwilteam/kwil-db v0.8.1 h1:0cDUVFO05FsUycTWThMP9+c15xVozY/3ex9/vH0XPps=
github.com/kwilteam/kwil-db v0.8.1/go.mod h1:izF+lVo00W94po9bADhPbBhLxLTArruxSTFO19UbpDY=
github.com/kwilteam/kwil-db v0.8.4 h1:LBM6JYS85K8A3grRuv25Z9vDPnET3a1eB6/K8cgjqSE=
github.com/kwilteam/kwil-db v0.8.4/go.mod h1:hc6jizGLENgXRSc9atk1IucKkWW+iNWU9U/sBzTj9ZE=
github.com/kwilteam/kwil-db/core v0.2.1 h1:k3X281LOiA01/egqbfiFXORVI/4pbj1ROsop6p5ACTs=
github.com/kwilteam/kwil-db/core v0.2.1/go.mod h1:IZX/X9cPUg1Ppet0MCsBV/Kot6JCikiITcahzSp2i3c=
github.com/kwilteam/kwil-db/parse v0.2.1 h1:/JTJ+ns8EfRrlnLWn+FOjUyrTC9T0KJMhBleBJWRLQ8=
github.com/kwilteam/kwil-db/parse v0.2.1/go.mod h1:zO/oGE5wbrZGOwVOOmHRs1R4xt2k2qD5tbO+dTC/WqU=
github.com/kwilteam/kwil-db/parse v0.2.4 h1:T5W0mABK6sg+eSNhO+3wK8ZDWrawr9D1HQ5PItEN5QY=
github.com/kwilteam/kwil-db/parse v0.2.4/go.mod h1:zO/oGE5wbrZGOwVOOmHRs1R4xt2k2qD5tbO+dTC/WqU=
github.com/kwilteam/kwil-extensions v0.0.0-20230727040522-1cfd930226b7 h1:YiPBu0pOeYOtOVfwKQqdWB07SUef9LvngF4bVFD+x34=
github.com/kwilteam/kwil-extensions v0.0.0-20230727040522-1cfd930226b7/go.mod h1:+BrFrV+3qcdYIfptqjwatE5gT19azuRHJzw77wMPY8c=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
Expand Down
2 changes: 1 addition & 1 deletion scripts/kwil_binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ download_binaries() {
fi

# Set the URL for the binary
URL="https://github.com/kwilteam/kwil-db/releases/download/v0.8.1/kwil-db_0.8.1_${OS}_${ARCH}.tar.gz"
URL="https://github.com/kwilteam/kwil-db/releases/download/v0.8.4/kwil-db_0.8.4_${OS}_${ARCH}.tar.gz"

echo "Detected platform: ${OS}-${ARCH}"
echo "Downloading binary from $URL..."
Expand Down