GetInterchain: perChain + chains options (default first anchor per chain)
Transaction.GetInterchain and Block.GetInterchain take variadic options (client.WithPerChain / client.WithChains, re-exported as sdk.WithPerChain / sdk.WithChains) that map to the new prime-node ?perChain=&chains= query params. Backward compatible: existing no-option calls get the default (one anchor per chain). client.InterchainQuery builds the suffix; unit-tested.
This commit is contained in:
22
client/interchain_test.go
Normal file
22
client/interchain_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package client
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestInterchainQuery(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
opts []InterchainOption
|
||||
want string
|
||||
}{
|
||||
{"none", nil, ""},
|
||||
{"perChain1", []InterchainOption{WithPerChain(1)}, "?perChain=1"},
|
||||
{"perChain0 (all)", []InterchainOption{WithPerChain(0)}, "?perChain=0"},
|
||||
{"chains", []InterchainOption{WithChains("1", "0")}, "?chains=1,0"},
|
||||
{"both", []InterchainOption{WithPerChain(2), WithChains("1", "0")}, "?perChain=2&chains=1,0"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := InterchainQuery(c.opts...); got != c.want {
|
||||
t.Errorf("%s: InterchainQuery = %q, want %q", c.name, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user