From 1a4f68768c06787c9d5b28e4254792ed1f1e1789 Mon Sep 17 00:00:00 2001 From: Ran Mishael Date: Sun, 25 Aug 2024 19:39:50 +0200 Subject: [PATCH] fix test --- protocol/rpcconsumer/relay_processor_test.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/protocol/rpcconsumer/relay_processor_test.go b/protocol/rpcconsumer/relay_processor_test.go index f773ebcc42..86018023d7 100644 --- a/protocol/rpcconsumer/relay_processor_test.go +++ b/protocol/rpcconsumer/relay_processor_test.go @@ -44,7 +44,7 @@ func sendSuccessResp(relayProcessor *RelayProcessor, provider string, delay time RelaySession: &pairingtypes.RelaySession{}, RelayData: &pairingtypes.RelayPrivateData{}, }, - Reply: &pairingtypes.RelayReply{Data: []byte("ok")}, + Reply: &pairingtypes.RelayReply{Data: []byte("ok"), LatestBlock: 1}, ProviderInfo: common.ProviderInfo{ProviderAddress: provider}, StatusCode: http.StatusOK, }, @@ -133,9 +133,18 @@ func TestRelayProcessorHappyFlow(t *testing.T) { returnedResult, err := relayProcessor.ProcessingResult() require.NoError(t, err) require.Equal(t, string(returnedResult.Reply.Data), "ok") - - seenBlock, found := consistency.GetSeenBlock(protocolMessage.GetUserData().DappId, protocolMessage.GetUserData().ConsumerIp) - fmt.Println(seenBlock, found) + var seenBlock int64 + var found bool + // wait for cache to be added asynchronously + for i := 0; i < 10; i++ { + seenBlock, found = consistency.GetSeenBlock(protocolMessage.GetUserData().DappId, protocolMessage.GetUserData().ConsumerIp) + if found { + break + } + time.Sleep(10 * time.Millisecond) + } + require.True(t, found) + require.Equal(t, seenBlock, int64(1)) }) }