Skip to content

Commit

Permalink
fix(logic): fix test after reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Feb 23, 2023
1 parent daaf1d3 commit bd57659
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions x/logic/predicate/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import (
//
// # Example:
//
// - Convert the given bech32 address into base64 encoded byte by unify the prefix of given address (Hrp) and
// the base64 encoded value (Address).
// - Convert the given bech32 address into base64 encoded byte by unify the prefix of given address (Hrp) and
// the base64 encoded value (Address).
//
// bech32_address(-(Hrp, Address), 'okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn').
// bech32_address(-(Hrp, Address), 'okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn').
//
// - Convert the given pair of HRP and base64 encoded address byte by unify the Bech32 string encoded value.
// - Convert the given pair of HRP and base64 encoded address byte by unify the Bech32 string encoded value.
//
// bech32_address(-('okp4', [163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]), Bech32).
// bech32_address(-('okp4', [163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]), Bech32).
func Bech32Address(vm *engine.VM, address, bech32 engine.Term, cont engine.Cont, env *engine.Env) *engine.Promise {
return engine.Delay(func(ctx context.Context) *engine.Promise {
switch b := env.Resolve(bech32).(type) {
Expand Down
8 changes: 4 additions & 4 deletions x/logic/predicate/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ func TestBech32(t *testing.T) {
},
{
query: `bech32_address(-('okp4', ['8956',167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]), Bech32).`,
wantError: fmt.Errorf("bech32_address/2: failed convert term to bytes list: invalid term type in list engine.Atom, only integer allowed"),
wantError: fmt.Errorf("bech32_address/2: failed to convert term to bytes list: invalid term type in list engine.Atom, only integer allowed"),
wantSuccess: false,
},
{
query: `bech32_address(-(Hrp, [163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]), Bech32).`,
wantError: fmt.Errorf("bech32_address/2: HRP should be instantiated when trying convert bytes to bech32"),
wantError: fmt.Errorf("bech32_address/2: HRP should be instantiated"),
wantSuccess: false,
},
{
query: `bech32_address(-('okp4', hey(2)), Bech32).`,
wantError: fmt.Errorf("bech32_address/2: address should be a List of bytes, give hey/1"),
wantError: fmt.Errorf("bech32_address/2: address should be a List of bytes"),
wantSuccess: false,
},
{
Expand All @@ -105,7 +105,7 @@ func TestBech32(t *testing.T) {
},
{
query: `bech32_address(Address, Bech32).`,
wantError: fmt.Errorf("bech32_address/2: you should give at least on instantiated value (Address or Bech32)"),
wantError: fmt.Errorf("bech32_address/2: invalid address type: engine.Variable, should be Compound (Hrp, Address)"),
wantSuccess: false,
},
}
Expand Down

0 comments on commit bd57659

Please sign in to comment.