From 9a408677d44bf75a3096784e286db58f57ddd223 Mon Sep 17 00:00:00 2001 From: thiagodeev Date: Fri, 24 May 2024 10:15:17 -0300 Subject: [PATCH] TestCall refactored --- rpc/call_test.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/rpc/call_test.go b/rpc/call_test.go index d2d62572..bfff3231 100644 --- a/rpc/call_test.go +++ b/rpc/call_test.go @@ -2,7 +2,6 @@ package rpc import ( "context" - "log" "testing" "github.com/NethermindEth/juno/core/felt" @@ -82,21 +81,18 @@ func TestCall(t *testing.T) { }[testEnv] for _, test := range testSet { + require := require.New(t) + spy := NewSpy(testConfig.provider.c) testConfig.provider.c = spy output, err := testConfig.provider.Call(context.Background(), FunctionCall(test.FunctionCall), test.BlockID) - if err != nil { - t.Fatal(err) - } - if diff, err := spy.Compare(output, false); err != nil || diff != "FullMatch" { - if _, err := spy.Compare(output, true); err != nil { - log.Fatal(err) - } - t.Fatal("expecting to match", err) - } - if len(output) == 0 { - t.Fatal("should return an output") - } - require.Equal(t, test.ExpectedPatternResult, output[0]) + require.NoError(err) + require.NotEmpty(output, "should return an output") + + diff, err := spy.Compare(output, false) + require.NoError(err) + require.Equal(diff, "FullMatch", "expecting to match") + + require.Equal(test.ExpectedPatternResult, output[0]) } }