Skip to content

Commit

Permalink
txCond HexOrDecimal
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdiallam committed Oct 28, 2024
1 parent 7b56c73 commit 33c3c9f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
13 changes: 8 additions & 5 deletions core/types/gen_transaction_conditional_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/types/transaction_conditional.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (ka *KnownAccount) UnmarshalJSON(data []byte) error {
}

// MarshalJSON will serialize the KnownAccount into JSON bytes.
func (ka *KnownAccount) MarshalJSON() ([]byte, error) {
func (ka KnownAccount) MarshalJSON() ([]byte, error) {
if ka.StorageRoot != nil {
return json.Marshal(ka.StorageRoot)
}
Expand Down
21 changes: 19 additions & 2 deletions core/types/transaction_conditional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,21 @@ func TestTransactionConditionalSerDeser(t *testing.T) {
},
{
name: "BlockNumberMax",
input: `{"blockNumberMin":"0x1", "blockNumberMax":"0x2"}`,
input: `{"blockNumberMax":"0x2"}`,
mustFail: false,
expected: TransactionConditional{
BlockNumberMin: big.NewInt(1),
BlockNumberMax: big.NewInt(2),
},
},
{
name: "BlockNumber (decimal)",
input: `{"blockNumberMin": 0, "blockNumberMax": 1}`,
mustFail: false,
expected: TransactionConditional{
BlockNumberMin: big.NewInt(0),
BlockNumberMax: big.NewInt(1),
},
},
{
name: "TimestampMin",
input: `{"timestampMin":"0xffff"}`,
Expand All @@ -227,6 +235,15 @@ func TestTransactionConditionalSerDeser(t *testing.T) {
TimestampMax: uint64Ptr(uint64(0xffffff)),
},
},
{
name: "Timestamp (decimal)",
input: `{"timestampMin": 0, "timestampMax": 1}`,
mustFail: false,
expected: TransactionConditional{
TimestampMin: uint64Ptr(0),
TimestampMax: uint64Ptr(1),
},
},
{
name: "UnknownField",
input: `{"foobarbaz": 1234}`,
Expand Down

0 comments on commit 33c3c9f

Please sign in to comment.