Skip to content

Commit

Permalink
chore: run nwaku as github action
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Apr 26, 2024
1 parent 78b1da7 commit eea2142
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .github/docker-compose/nwaku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
nwaku:
image: "quay.io/wakuorg/nwaku-pr:2636-rln-v2"
command: ["--relay --store --nodekey=1122334455667788990011223344556677889900112233445566778899001122"]
ports:
- "60000"
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,9 @@ jobs:
run: |
docker compose -f .github/docker-compose/ganache.yml up -d
make test-onchain${{ matrix.tests == 'test-with-race' && '-with-race' || '' }}
- name: "Run storev3 tests"
run: |
docker compose -f .github/docker-compose/nwaku.yml up -d
nwaku_port=$(docker-compose port nwaku 60000)
echo "Mapped port for nwaku: $nwaku_port"
4 changes: 3 additions & 1 deletion waku/persistence/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,10 @@ func (d *DBStore) Put(env *protocol.Envelope) error {
storedAt = env.Index().ReceiverTime
}

hash := env.Hash()

start := time.Now()
_, err = stmt.Exec(env.Index().Digest, env.Hash(), storedAt, env.Message().GetTimestamp(), env.Message().ContentTopic, env.PubsubTopic(), env.Message().Payload, env.Message().GetVersion())
_, err = stmt.Exec(env.Index().Digest, hash[:], storedAt, env.Message().GetTimestamp(), env.Message().ContentTopic, env.PubsubTopic(), env.Message().Payload, env.Message().GetVersion())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion waku/v2/protocol/envelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestEnvelope(t *testing.T) {

require.Equal(
t,
[]byte{0x91, 0x0, 0xe4, 0xa5, 0xcf, 0xf7, 0x19, 0x27, 0x49, 0x81, 0x66, 0xb3, 0xdf, 0xc7, 0xa6, 0x31, 0xf0, 0x87, 0xc7, 0x29, 0xb4, 0x28, 0x83, 0xb9, 0x5c, 0x31, 0x25, 0x33, 0x3, 0xc9, 0x7, 0x95},
pb.ToMessageHash([]byte{0x91, 0x0, 0xe4, 0xa5, 0xcf, 0xf7, 0x19, 0x27, 0x49, 0x81, 0x66, 0xb3, 0xdf, 0xc7, 0xa6, 0x31, 0xf0, 0x87, 0xc7, 0x29, 0xb4, 0x28, 0x83, 0xb9, 0x5c, 0x31, 0x25, 0x33, 0x3, 0xc9, 0x7, 0x95}),
hash,
)
}
12 changes: 6 additions & 6 deletions waku/v2/protocol/pb/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestEnvelopeHash(t *testing.T) {

expected := []byte{0xb6, 0x59, 0x60, 0x7f, 0x2a, 0xae, 0x18, 0x84, 0x8d, 0xca, 0xa7, 0xd5, 0x1c, 0xb3, 0x7e, 0x6c, 0xc6, 0xfc, 0x33, 0x40, 0x2c, 0x70, 0x4f, 0xf0, 0xc0, 0x16, 0x33, 0x7d, 0x83, 0xad, 0x61, 0x50}
result := msg.Hash("test")
require.Equal(t, expected, result)
require.Equal(t, ToMessageHash(expected), result)
}

func TestEmptyMeta(t *testing.T) {
Expand All @@ -38,7 +38,7 @@ func TestEmptyMeta(t *testing.T) {

messageHash := msg.Hash(pubsubTopic)

require.Equal(t, "f0183c2e370e473ff471bbe1028d0d8a940949c02f3007a1ccd21fed356852a0", messageHash.String())
require.Equal(t, "0xf0183c2e370e473ff471bbe1028d0d8a940949c02f3007a1ccd21fed356852a0", messageHash.String())
}

func Test13ByteMeta(t *testing.T) {
Expand All @@ -52,7 +52,7 @@ func Test13ByteMeta(t *testing.T) {

messageHash := msg.Hash(pubsubTopic)

require.Equal(t, "f673cd2c9c973d685b52ca74c2559e001733a3a31a49ffc7b6e8713decba5a55", messageHash.String())
require.Equal(t, "0xf673cd2c9c973d685b52ca74c2559e001733a3a31a49ffc7b6e8713decba5a55", messageHash.String())
}

func TestZeroLenPayload(t *testing.T) {
Expand All @@ -66,7 +66,7 @@ func TestZeroLenPayload(t *testing.T) {

messageHash := msg.Hash(pubsubTopic)

require.Equal(t, "978ccc9a665029f9829d42d84e3a49ad3a4791cce53fb5a8b581ef43ad6b4d2f", messageHash.String())
require.Equal(t, "0x978ccc9a665029f9829d42d84e3a49ad3a4791cce53fb5a8b581ef43ad6b4d2f", messageHash.String())
}

func TestHashWithTimestamp(t *testing.T) {
Expand All @@ -78,11 +78,11 @@ func TestHashWithTimestamp(t *testing.T) {
msg.Version = proto.Uint32(1)

messageHash := msg.Hash(pubsubTopic)
require.Equal(t, "58e2fc032a82c4adeb967a8b87086d0d6fb304912f120d4404e6236add8f1f56", messageHash.String())
require.Equal(t, "0x58e2fc032a82c4adeb967a8b87086d0d6fb304912f120d4404e6236add8f1f56", messageHash.String())

msg.Timestamp = proto.Int64(123456789123456789)
messageHash = msg.Hash(pubsubTopic)
require.Equal(t, "978ccc9a665029f9829d42d84e3a49ad3a4791cce53fb5a8b581ef43ad6b4d2f", messageHash.String())
require.Equal(t, "0x978ccc9a665029f9829d42d84e3a49ad3a4791cce53fb5a8b581ef43ad6b4d2f", messageHash.String())
}

func TestIntToBytes(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions waku/v2/protocol/store/client_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package store
//go:build include_storev3_tests
// +build include_storev3_tests

//111go:build include_storev3_tests
// 111+build include_storev3_tests
package store

import (
"context"
Expand Down Expand Up @@ -43,7 +43,7 @@ func TestStoreClient(t *testing.T) {
err = wakuRelay.Start(context.Background())
require.NoError(t, err)

pm := peermanager.NewPeerManager(5, 5, utils.Logger())
pm := peermanager.NewPeerManager(5, 5, nil, utils.Logger())
pm.SetHost(host)
err = pm.SubscribeToRelayEvtBus(wakuRelay.Events())
require.NoError(t, err)
Expand Down

0 comments on commit eea2142

Please sign in to comment.