diff --git a/account/account_test.go b/account/account_test.go index 1d6a82bb..91097805 100644 --- a/account/account_test.go +++ b/account/account_test.go @@ -1067,7 +1067,7 @@ func TestWaitForTransactionReceipt(t *testing.T) { type testSetType struct { Timeout int Hash *felt.Felt - ExpectedErr *rpc.RPCError + ExpectedErr error ExpectedReceipt rpc.TransactionReceipt } testSet := map[string][]testSetType{ @@ -1087,10 +1087,7 @@ func TestWaitForTransactionReceipt(t *testing.T) { resp, err := acnt.WaitForTransactionReceipt(ctx, test.Hash, 1*time.Second) if test.ExpectedErr != nil { - rpcErr, ok := err.(*rpc.RPCError) - require.True(t, ok) - require.Equal(t, test.ExpectedErr.Code, rpcErr.Code) - require.Equal(t, test.ExpectedErr.Message, rpcErr.Message) + require.Equal(t, test.ExpectedErr.Error(), err.Error()) } else { require.Equal(t, test.ExpectedReceipt.ExecutionStatus, (*resp).ExecutionStatus) } diff --git a/rpc/call_test.go b/rpc/call_test.go index b12dabc4..a1823ec2 100644 --- a/rpc/call_test.go +++ b/rpc/call_test.go @@ -30,7 +30,7 @@ func TestCall(t *testing.T) { FunctionCall FunctionCall BlockID BlockID ExpectedPatternResult *felt.Felt - ExpectedError *RPCError + ExpectedError error } testSet := map[string][]testSetType{ "devnet": { @@ -108,14 +108,10 @@ func TestCall(t *testing.T) { }[testEnv] for _, test := range testSet { - // TODO: create a test case for the new 'CONTRACT_EXECUTION_ERROR' type" require := require.New(t) output, err := testConfig.provider.Call(context.Background(), FunctionCall(test.FunctionCall), test.BlockID) if test.ExpectedError != nil { - rpcErr, ok := err.(*RPCError) - require.True(ok) - require.Equal(test.ExpectedError.Code, rpcErr.Code) - require.Equal(test.ExpectedError.Message, rpcErr.Message) + require.EqualError(test.ExpectedError, err.Error()) } else { require.NoError(err) require.NotEmpty(output, "should return an output") diff --git a/rpc/contract_test.go b/rpc/contract_test.go index 029bfce9..7c0a23c2 100644 --- a/rpc/contract_test.go +++ b/rpc/contract_test.go @@ -404,7 +404,7 @@ func TestEstimateMessageFee(t *testing.T) { MsgFromL1 BlockID ExpectedFeeEst *FeeEstimation - ExpectedError *RPCError + ExpectedError error } // https://sepolia.voyager.online/message/0x273f4e20fc522098a60099e5872ab3deeb7fb8321a03dadbd866ac90b7268361 @@ -470,10 +470,7 @@ func TestEstimateMessageFee(t *testing.T) { for _, test := range testSet { resp, err := testConfig.provider.EstimateMessageFee(context.Background(), test.MsgFromL1, test.BlockID) if err != nil { - rpcErr, ok := err.(*RPCError) - require.True(t, ok) - require.Equal(t, test.ExpectedError.Code, rpcErr.Code) - require.Equal(t, test.ExpectedError.Message, rpcErr.Message) + require.EqualError(t, test.ExpectedError, err.Error()) } else { require.Exactly(t, test.ExpectedFeeEst, resp) } diff --git a/rpc/errors_test.go b/rpc/errors_test.go index 86c2411c..e0981d3b 100644 --- a/rpc/errors_test.go +++ b/rpc/errors_test.go @@ -8,7 +8,6 @@ import ( ) func TestRPCError(t *testing.T) { - t.Skip("TODO: test the new RPCData field before merge") if testEnv == "mock" { testConfig := beforeEach(t) _, err := testConfig.provider.ChainID(context.Background()) diff --git a/rpc/write_test.go b/rpc/write_test.go index c56c73b9..005d367f 100644 --- a/rpc/write_test.go +++ b/rpc/write_test.go @@ -2,6 +2,7 @@ package rpc import ( "context" + "errors" "testing" "github.com/NethermindEth/juno/core/felt" @@ -16,7 +17,7 @@ func TestDeclareTransaction(t *testing.T) { type testSetType struct { DeclareTx BroadcastDeclareTxnType ExpectedResp AddDeclareTransactionResponse - ExpectedError *RPCError + ExpectedError error } testSet := map[string][]testSetType{ "devnet": {}, @@ -39,7 +40,7 @@ func TestDeclareTransaction(t *testing.T) { DeclareTx: BroadcastDeclareTxnV1{}, ExpectedResp: AddDeclareTransactionResponse{ TransactionHash: utils.TestHexToFelt(t, "0x55b094dc5c84c2042e067824f82da90988674314d37e45cb0032aca33d6e0b9")}, - ExpectedError: &RPCError{Code: InvalidParams, Message: "Invalid Params"}, + ExpectedError: errors.New("Invalid Params"), }, }, }[testEnv] @@ -47,10 +48,7 @@ func TestDeclareTransaction(t *testing.T) { for _, test := range testSet { resp, err := testConfig.provider.AddDeclareTransaction(context.Background(), test.DeclareTx) if err != nil { - rpcErr, ok := err.(*RPCError) - require.True(t, ok) - require.Equal(t, test.ExpectedError.Code, rpcErr.Code) - require.Equal(t, test.ExpectedError.Message, rpcErr.Message) + require.Equal(t, test.ExpectedError.Error(), err.Error()) } else { require.Equal(t, (*resp.TransactionHash).String(), (*test.ExpectedResp.TransactionHash).String()) }