Skip to content

Commit

Permalink
UT for marshal/unmarshal of log
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed May 2, 2023
1 parent 3933af1 commit c76923c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions consensus/polybft/stake_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi"
"github.com/0xPolygon/polygon-edge/consensus/polybft/wallet"
"github.com/0xPolygon/polygon-edge/contracts"
"github.com/0xPolygon/polygon-edge/helper/hex"
"github.com/0xPolygon/polygon-edge/txrelayer"
"github.com/0xPolygon/polygon-edge/types"
Expand Down Expand Up @@ -248,6 +249,29 @@ func TestStakeCounter_ShouldBeDeterministic(t *testing.T) {
}
}

func TestStakeManager_RLPEncoding_Log(t *testing.T) {
t.Parallel()

testLog := createTestLogForTransferEvent(t, contracts.ValidatorSetContract,
types.StringToAddress("0x00001111111"), types.StringToAddress("0x00002222222"), 10000000000000)

receipt := &types.Receipt{
Root: types.ZeroHash,
CumulativeGasUsed: 1111111,
Logs: []*types.Log{testLog},
GasUsed: 1111111,
TxHash: types.ZeroHash,
ContractAddress: &contracts.ValidatorSetContract,
}

marshalled := receipt.MarshalRLP()

unmarshalledReceipt := &types.Receipt{}
require.NoError(t, unmarshalledReceipt.UnmarshalRLP(marshalled))
require.Len(t, receipt.Logs, 1)
require.Equal(t, receipt.Logs[0].Data, testLog.Data)
}

func createTestLogForTransferEvent(t *testing.T, validatorSet, from, to types.Address, stake uint64) *types.Log {
t.Helper()

Expand Down

0 comments on commit c76923c

Please sign in to comment.