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.
23 lines
652 B
Go
23 lines
652 B
Go
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)
|
|
}
|
|
}
|
|
}
|