Skip to content

Commit

Permalink
add two more unit tests for missed lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Oct 10, 2024
1 parent 416b8d4 commit c48d999
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/memo/codec_compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ func Test_CodecCompact_UnpackArguments(t *testing.T) {
memo.ArgRevertAddress(""),
},
},
{
name: "failed to unpack address if data length < 20 bytes",
encodingFmt: memo.EncodingFmtCompactShort,
data: []byte{0x01, 0x02, 0x03, 0x04, 0x05},
expected: []memo.CodecArg{
memo.ArgReceiver(argAddress),
},
errMsg: "expected address, got 5 bytes",
},
{
name: "failed to unpack string if data length < 1 byte",
encodingFmt: memo.EncodingFmtCompactShort,
Expand Down
8 changes: 8 additions & 0 deletions pkg/memo/fields_v0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ func Test_V0_Unpack(t *testing.T) {
Payload: []byte{},
},
},
{
name: "unable to get codec on invalid encoding format",
opCode: memo.OpCodeDepositAndCall,
encodingFormat: 0x0F,
flags: 0b00000001,
data: []byte{},
errMsg: "unable to get codec",
},
{
name: "failed to unpack ABI encoded data with compact encoding format",
opCode: memo.OpCodeDepositAndCall,
Expand Down

0 comments on commit c48d999

Please sign in to comment.