-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(eibc): improve eibc memo error handling (#838)
Co-authored-by: Omri <[email protected]>
- Loading branch information
1 parent
ac95ebf
commit 9f7fd4e
Showing
13 changed files
with
192 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package types | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func Test_parsePacketMetadata(t *testing.T) { | ||
type args struct { | ||
input string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want *PacketMetadata | ||
wantErr bool | ||
}{ | ||
{ | ||
"valid", | ||
args{ | ||
`{"eibc":{"fee":"100"}}`, | ||
}, | ||
&PacketMetadata{ | ||
EIBC: &EIBCMetadata{ | ||
Fee: "100", | ||
}, | ||
}, | ||
false, | ||
}, | ||
{ | ||
"invalid - misquoted fee", | ||
args{ | ||
`{"eibc":{"fee":100}}`, | ||
}, | ||
nil, | ||
true, | ||
}, | ||
{ | ||
"invalid - pfm", | ||
args{ | ||
`{"forward":{}}`, | ||
}, | ||
nil, | ||
true, | ||
}, | ||
{ | ||
"invalid - empty", | ||
args{ | ||
``, | ||
}, | ||
nil, | ||
true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := ParsePacketMetadata(tt.args.input) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("parsePacketMetadata() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("parsePacketMetadata() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.