Skip to content

Commit

Permalink
revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagodeev committed Dec 19, 2024
1 parent c95363b commit 40b47a6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
7 changes: 2 additions & 5 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
}
Expand Down
8 changes: 2 additions & 6 deletions rpc/call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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")
Expand Down
7 changes: 2 additions & 5 deletions rpc/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func TestEstimateMessageFee(t *testing.T) {
MsgFromL1
BlockID
ExpectedFeeEst *FeeEstimation
ExpectedError *RPCError
ExpectedError error
}

// https://sepolia.voyager.online/message/0x273f4e20fc522098a60099e5872ab3deeb7fb8321a03dadbd866ac90b7268361
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion rpc/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
10 changes: 4 additions & 6 deletions rpc/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rpc

import (
"context"
"errors"
"testing"

"github.com/NethermindEth/juno/core/felt"
Expand All @@ -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": {},
Expand All @@ -39,18 +40,15 @@ 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]

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())
}
Expand Down

0 comments on commit 40b47a6

Please sign in to comment.