Skip to content

Commit

Permalink
update test to require.Equal all fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Mar 8, 2024
1 parent 79cf7f1 commit 6759494
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions rpc/types_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
_ "embed"
"encoding/json"
"errors"
"os"
"testing"

"github.com/NethermindEth/juno/core/felt"
Expand Down Expand Up @@ -134,21 +135,23 @@ func TestBlockWithReceipts(t *testing.T) {
ctx := context.Background()

type testSetType struct {
BlockID BlockID
ExpectedBlock Block
ExpectedErr *RPCError
BlockID BlockID
ExpectedBlockWithReceipts BlockWithReceipts
ExpectedErr *RPCError
}

var expectedBlockWithReceipts struct {
Result BlockWithReceipts `json:"result"`
}
read, err := os.ReadFile("tests/blockWithReceipts/integration332275.json")
require.Nil(t, err)
require.Nil(t, json.Unmarshal(read, &expectedBlockWithReceipts))

testSet := map[string][]testSetType{
"mock": {testSetType{
BlockID: BlockID{Tag: "greatest block"},
ExpectedBlock: Block{
Status: BlockStatus_AcceptedOnL2,
BlockHeader: BlockHeader{
BlockNumber: 332275,
},
},
ExpectedErr: nil,
BlockID: BlockID{Tag: "tests/blockWithReceipts/integration332275.json"},
ExpectedBlockWithReceipts: expectedBlockWithReceipts.Result,
ExpectedErr: nil,
},
},
}[testEnv]
Expand All @@ -159,15 +162,7 @@ func TestBlockWithReceipts(t *testing.T) {
block, err := provider.BlockWithReceipts(ctx, test.BlockID)
require.Nil(t, err)
blockCasted := block.(*BlockWithReceipts)
txsWithReceipts := blockCasted.BlockBodyWithReceipts.Transactions
require.Equal(t, blockCasted.BlockStatus, test.ExpectedBlock.Status)
require.Equal(t, blockCasted.BlockNumber, test.ExpectedBlock.BlockNumber)
require.NotZero(t, len(blockCasted.Transactions))
require.NotNil(t, blockCasted.L1GasPrice)
require.NotNil(t, blockCasted.L1DataGasPrice)
require.NotNil(t, txsWithReceipts)
require.NotNil(t, txsWithReceipts[0].Transaction)
require.NotNil(t, txsWithReceipts[0].Receipt)
require.Equal(t, test.ExpectedBlockWithReceipts, *blockCasted)

})
}
Expand Down

0 comments on commit 6759494

Please sign in to comment.