Files
iam/internal/wallet/chains_test.go
zeekayandHanzo Dev 084011934f legal: dual MIT OR Apache-2.0, canonical licence text
This repo is public and its LICENSE called the source "confidential and
proprietary ... All rights reserved". Public visibility contradicts
confidentiality, and HIP-0130 puts `iam` in the OSS core tier. The declaration
now matches both.

LICENSE-APACHE and LICENSE-MIT carry the canonical texts, unedited —
LICENSE-APACHE is byte-identical to apache.org/licenses/LICENSE-2.0.txt
(sha256 cfc7749b…, 11358 bytes, blob d645695). LICENSE declares the pair.
LICENSE-MIT carries the copyright line the notice requires.

249 Go files led with `// Copyright 2026 Hanzo AI, Inc. All rights reserved.`
— the classic proprietary reservation, and a per-file contradiction of the new
grant. Each now carries `// SPDX-License-Identifier: MIT OR Apache-2.0`. The
word "confidential" survives untouched in the OIDC sense (confidential client),
which is protocol vocabulary, not a licence claim.

There is nothing else to declare: `go.mod` has no licence field and this repo
ships no Cargo/npm/PyPI manifest.

Relicensing is ours alone to do. The tree is original work, not a fork:
`fork: false` with no parent, its own root commit, and no Casdoor-lineage tag
is an ancestor of `main`. The retired Casdoor fork is `hanzoai/iam-v1`; the
provenance note in LICENSE names it, restoring the vendor name a clean-room
assertion needs in order to say what it is clean of.

Build, vet and all 29 test packages green.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-04 01:09:51 -07:00

56 lines
1.9 KiB
Go

// Copyright 2026 Hanzo AI, Inc.
// SPDX-License-Identifier: MIT OR Apache-2.0
package wallet
import (
"testing"
wc "github.com/luxwallet/connect/go/walletconnect"
"github.com/hanzoai/iam/pkg/schema"
)
// schema.WalletChains carries NAMES so that package stays dependency-free, which
// buys the leaf both the endpoints and the login descriptor can import — but a
// name is only as good as its agreement with the luxwallet constant it stands
// for. This is where that agreement is enforced, in the one package that imports
// both. A rename upstream fails here instead of silently narrowing what can sign
// in: a chain whose name stopped matching would be advertised and then refused,
// which is the exact screen-vs-endpoint disagreement the shared list exists to
// prevent.
func TestWalletChainsMatchSDK(t *testing.T) {
want := []wc.Chain{
wc.ChainEVM, wc.ChainSolana, wc.ChainBitcoin,
wc.ChainTON, wc.ChainXRP, wc.ChainPolkadot, wc.ChainCardano,
}
got := schema.WalletChains()
if len(got) != len(want) {
t.Fatalf("schema.WalletChains() has %d chains, the SDK set has %d: %v vs %v",
len(got), len(want), got, want)
}
for i, w := range want {
if got[i] != string(w) {
t.Errorf("chain %d = %q, want %q (the luxwallet constant)", i, got[i], string(w))
}
}
}
// Every advertised chain must be one the endpoints accept, and nothing else may
// be. This is the property that matters: the list is only worth sharing if both
// halves genuinely read it.
func TestAdvertisedChainsAreExactlyTheSupportedOnes(t *testing.T) {
for _, name := range schema.WalletChains() {
if !supported(wc.Chain(name)) {
t.Errorf("advertised chain %q is refused by supported() — a screen would offer "+
"a wallet the nonce endpoint then rejects", name)
}
}
for _, bogus := range []string{"dogecoin", "", "EVM ", "eip155:1"} {
if supported(wc.Chain(bogus)) {
t.Errorf("supported(%q) = true; only the shared list may pass", bogus)
}
}
}