Files
prime-sdk-go/client/interchain_test.go
Andrew Miller 17057ad1f2 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.
2026-06-05 10:54:45 -04:00

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)
}
}
}