Skip to content

Commit

Permalink
fixing statistical tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ranlavanet committed Sep 3, 2024
1 parent 5bf5004 commit b95a617
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
7 changes: 7 additions & 0 deletions protocol/rpcconsumer/consumer_relay_state_machine_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package rpcconsumer

import "testing"

func TestConsumerStateMachineHappyFlow(t *testing.T) {

Check failure on line 6 in protocol/rpcconsumer/consumer_relay_state_machine_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
}
21 changes: 16 additions & 5 deletions protocol/rpcconsumer/relay_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,12 +512,21 @@ func TestRelayProcessorStatefulApi(t *testing.T) {
go sendNodeError(relayProcessor, "lava2@test", time.Millisecond*20)
go sendNodeError(relayProcessor, "lava3@test", time.Millisecond*25)
go sendSuccessResp(relayProcessor, "lava4@test", time.Millisecond*100)
ctx, cancel = context.WithTimeout(context.Background(), time.Millisecond*200)
ctx, cancel = context.WithTimeout(context.Background(), time.Millisecond*300)
defer cancel()
err = relayProcessor.WaitForResults(ctx)
require.NoError(t, err)
for i := 0; i < 10; i++ {
err := relayProcessor.WaitForResults(ctx)
require.NoError(t, err)
// Decide if we need to resend or not
if relayProcessor.HasRequiredNodeResults() {
break
}
time.Sleep(5 * time.Millisecond)
}
resultsOk := relayProcessor.HasResults()
require.True(t, resultsOk)
resultsOk = relayProcessor.HasRequiredNodeResults()
require.True(t, resultsOk)
protocolErrors := relayProcessor.ProtocolErrors()
require.Equal(t, uint64(1), protocolErrors)
returnedResult, err := relayProcessor.ProcessingResult()
Expand Down Expand Up @@ -559,8 +568,10 @@ func TestRelayProcessorStatefulApiErr(t *testing.T) {
go sendNodeError(relayProcessor, "lava3@test", time.Millisecond*25)
ctx, cancel = context.WithTimeout(context.Background(), time.Millisecond*50)
defer cancel()
err = relayProcessor.WaitForResults(ctx)
require.Error(t, err)
for i := 0; i < 2; i++ {
err = relayProcessor.WaitForResults(ctx)
require.NoError(t, err)
}
resultsOk := relayProcessor.HasResults()
require.True(t, resultsOk)
protocolErrors := relayProcessor.ProtocolErrors()
Expand Down

0 comments on commit b95a617

Please sign in to comment.