Skip to content

Commit

Permalink
test: gsoc listener
Browse files Browse the repository at this point in the history
  • Loading branch information
nugaon committed Sep 11, 2024
1 parent 5422710 commit 67bd8d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/pushsync/pushsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ func TestSocListener(t *testing.T) {
t.Fatal(err)
}
sch2 = sch2.WithStamp(chunk2.Stamp())
expectedPayload := chunk1.Data()
gsocListener := func(soc soc.SOC) {
if !bytes.Equal(soc.WrappedChunk().Data(), expectedPayload) {
t.Fatalf("unexpected SOC payload on GSOC listener. got %s, want %s", soc.WrappedChunk().Data(), expectedPayload)
}
}

// create a pivot node and a mocked closest node
pivotNode := swarm.MustParseHexAddress("0000000000000000000000000000000000000000000000000000000000000000") // base is 0000
Expand All @@ -143,7 +149,7 @@ func TestSocListener(t *testing.T) {

// pivot node needs the streamer since the chunk is intercepted by
// the chunk worker, then gets sent by opening a new stream
psPivot, _, _ := createGsocPushSyncNode(t, pivotNode, defaultPrices, recorder, nil, defaultSigner, mock.WithClosestPeer(closestPeer))
psPivot, _, _ := createGsocPushSyncNode(t, pivotNode, defaultPrices, recorder, gsocListener, defaultSigner, mock.WithClosestPeer(closestPeer))

// Trigger the sending of chunk to the closest node
receipt, err := psPivot.PushChunkToClosest(context.Background(), sch1)
Expand All @@ -162,6 +168,7 @@ func TestSocListener(t *testing.T) {
waitOnRecordAndTest(t, closestPeer, recorder, sch1.Address(), nil)

recorder.Reset()
expectedPayload = chunk2.Data()

// Trigger the sending of chunk to the closest node
receipt, err = psPivot.PushChunkToClosest(context.Background(), sch2)
Expand Down

0 comments on commit 67bd8d7

Please sign in to comment.