@@ -115,13 +115,19 @@ func TestTransferWithAuthorizationTypeHash(t *testing.T) {
115115}
116116
117117func TestUSDCDomainKnownChains (t * testing.T ) {
118- for _ , chainID := range []uint64 {ChainEthereumMainnet , ChainBaseMainnet , ChainBaseSepolia } {
118+ wantName := map [uint64 ]string {
119+ ChainEthereumMainnet : "USD Coin" ,
120+ ChainBaseMainnet : "USD Coin" ,
121+ ChainPolygonMainnet : "USD Coin" ,
122+ ChainBaseSepolia : "USDC" , // Circle's testnet deployment differs
123+ }
124+ for chainID , name := range wantName {
119125 d , err := USDCDomain (chainID )
120126 if err != nil {
121127 t .Fatalf ("USDCDomain(%d): %v" , chainID , err )
122128 }
123- if d .Name != "USD Coin" || d .Version != "2" || d .ChainID != chainID {
124- t .Errorf ("domain for chain %d wrong: %+v" , chainID , d )
129+ if d .Name != name || d .Version != "2" || d .ChainID != chainID {
130+ t .Errorf ("domain for chain %d wrong: %+v (want name %q) " , chainID , d , name )
125131 }
126132 // Separator must be 32 bytes.
127133 sep := d .Separator ()
@@ -131,6 +137,30 @@ func TestUSDCDomainKnownChains(t *testing.T) {
131137 }
132138}
133139
140+ // TestUSDCDomainSeparatorsMatchOnChain pins Domain.Separator() for every
141+ // supported chain to the value the deployed USDC contract returns from
142+ // DOMAIN_SEPARATOR() (fetched via eth_call, 2026-07-29). If any of these
143+ // fail, signatures produced for that chain are unverifiable on-chain —
144+ // this is the regression test for the Base Sepolia "USD Coin"/"USDC"
145+ // domain-name mismatch.
146+ func TestUSDCDomainSeparatorsMatchOnChain (t * testing.T ) {
147+ onChain := map [uint64 ]string {
148+ ChainEthereumMainnet : "06c37168a7db5138defc7866392bb87a741f9b3d104deb5094588ce041cae335" ,
149+ ChainBaseMainnet : "02fa7265e7c5d81118673727957699e4d68f74cd74b7db77da710fe8a2c7834f" ,
150+ ChainPolygonMainnet : "caa2ce1a5703ccbe253a34eb3166df60a705c561b44b192061e28f2a985be2ca" ,
151+ ChainBaseSepolia : "71f17a3b2ff373b803d70a5a07c046c1a2bc8e89c09ef722fcb047abe94c9818" ,
152+ }
153+ for chainID , want := range onChain {
154+ d , err := USDCDomain (chainID )
155+ if err != nil {
156+ t .Fatalf ("USDCDomain(%d): %v" , chainID , err )
157+ }
158+ if got := hex .EncodeToString (d .Separator ()); got != want {
159+ t .Errorf ("chain %d separator %s, on-chain DOMAIN_SEPARATOR() is %s" , chainID , got , want )
160+ }
161+ }
162+ }
163+
134164func TestUSDCDomainRejectsUnknownChain (t * testing.T ) {
135165 _ , err := USDCDomain (999999 )
136166 if err == nil {
0 commit comments