diff --git a/tools/docker-network/tests/dockertestframework/framework_eventapi.go b/tools/docker-network/tests/dockertestframework/framework_eventapi.go index b7a49f31f..b48758d2e 100644 --- a/tools/docker-network/tests/dockertestframework/framework_eventapi.go +++ b/tools/docker-network/tests/dockertestframework/framework_eventapi.go @@ -13,6 +13,7 @@ import ( "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/hive.go/lo" "github.com/iotaledger/hive.go/runtime/options" + "github.com/iotaledger/iota-core/pkg/protocol/engine/blocks" "github.com/iotaledger/iota-core/pkg/testsuite/mock" iotago "github.com/iotaledger/iota.go/v4" "github.com/iotaledger/iota.go/v4/api" @@ -61,7 +62,7 @@ func (e *EventAPIDockerTestFramework) ConnectEventAPIClient(ctx context.Context) } // SubmitDataBlockStream submits a stream of data blocks to the network for the given duration. -func (e *EventAPIDockerTestFramework) SubmitDataBlockStream(wallet *mock.Wallet, duration time.Duration, tick time.Duration, countPerTick int, blockSubmittedCallback func()) { +func (e *EventAPIDockerTestFramework) SubmitDataBlockStream(wallet *mock.Wallet, duration time.Duration, tick time.Duration, countPerTick int, blockSubmittedCallback func(*blocks.Block)) { timer := time.NewTimer(duration) defer timer.Stop() @@ -72,10 +73,10 @@ func (e *EventAPIDockerTestFramework) SubmitDataBlockStream(wallet *mock.Wallet, select { case <-ticker.C: for range countPerTick { - _, err := wallet.CreateAndSubmitBasicBlock(context.TODO(), "tagged_data_block", mock.WithPayload(tpkg.RandTaggedData([]byte("tag")))) + block, err := wallet.CreateAndSubmitBasicBlock(context.TODO(), "tagged_data_block", mock.WithPayload(tpkg.RandTaggedData([]byte("tag")))) require.NoError(e.Testing, err) - blockSubmittedCallback() + blockSubmittedCallback(block) } case <-timer.C: return diff --git a/tools/docker-network/tests/eventapi_test.go b/tools/docker-network/tests/eventapi_test.go index 509e60646..529e338e4 100644 --- a/tools/docker-network/tests/eventapi_test.go +++ b/tools/docker-network/tests/eventapi_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/iotaledger/iota-core/pkg/protocol/engine/blocks" "github.com/iotaledger/iota-core/pkg/testsuite/mock" "github.com/iotaledger/iota-core/tools/docker-network/tests/dockertestframework" iotago "github.com/iotaledger/iota.go/v4" @@ -501,13 +502,19 @@ func test_BlockMetadataMatchedCoreAPI(t *testing.T, e *dockertestframework.Event // issue blocks fmt.Println("Submitting blocks for 30s...") - e.SubmitDataBlockStream(account.Wallet(), 30*time.Second, 1*time.Second, 10, func() { + var maxSlot iotago.SlotIndex + e.SubmitDataBlockStream(account.Wallet(), 30*time.Second, 1*time.Second, 10, func(block *blocks.Block) { sentCounter.Add(1) + if block.ID().Slot() > maxSlot { + maxSlot = block.ID().Slot() + } }) + // wait until all blocks are committed + e.DockerTestFramework().AwaitCommittedSlot(maxSlot, true) + // wait until all topics receives all expected objects - fmt.Println("Waiting for receiving additional blocks for 5s...") - time.Sleep(5 * time.Second) + time.Sleep(1 * time.Second) // cancel listening cancel()