Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Add missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Castell committed Dec 21, 2023
1 parent a4521b1 commit dd02b88
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions rpc/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,37 @@ func TestArgUint64_UnmarshalText(t *testing.T) {
}
}

func TestArgUint64_Hex(t *testing.T) {
tests := []struct {
name string
arg ArgUint64
expected string
}{
{
name: "Positive number",
arg: ArgUint64(123),
expected: "0x7b",
},
{
name: "Zero",
arg: ArgUint64(0),
expected: "0x0",
},
{
name: "Large number",
arg: ArgUint64(18446744073709551615),
expected: "0xffffffffffffffff",
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
result := test.arg.Hex()
assert.Equal(t, test.expected, result)
})
}
}

func TestArgBytes_MarshalText(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -146,6 +177,32 @@ func TestArgBytes_UnmarshalText(t *testing.T) {
}
}

func TestArgBytes_Hex(t *testing.T) {
tests := []struct {
name string
arg ArgBytes
expected string
}{
{
name: "Non-empty bytes",
arg: ArgBytes{0x01, 0x02, 0x03},
expected: "0x010203",
},
{
name: "Empty bytes",
arg: ArgBytes{},
expected: "0x",
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
result := test.arg.Hex()
assert.Equal(t, test.expected, result)
})
}
}

func TestArgHash_UnmarshalText(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -184,3 +241,29 @@ func TestArgHash_UnmarshalText(t *testing.T) {
})
}
}

func TestArgHash_Hash(t *testing.T) {
tests := []struct {
name string
arg *ArgHash
expected common.Hash
}{
{
name: "Non-nil argument",
arg: &ArgHash{0x01, 0x02, 0x03},
expected: common.Hash{0x01, 0x02, 0x03},
},
{
name: "Nil argument",
arg: nil,
expected: common.Hash{},
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
result := test.arg.Hash()
assert.Equal(t, test.expected, result)
})
}
}

0 comments on commit dd02b88

Please sign in to comment.