@@ -2,6 +2,7 @@ package sequence_test
22
33import (
44 "context"
5+ "strings"
56 "testing"
67
78 "github.com/0xsequence/ethkit/go-ethereum/accounts"
@@ -12,7 +13,9 @@ import (
1213)
1314
1415// These tests require a live testchain (make start-testchain or make start-testchain-berachain).
15- // They create a Sequence wallet, sign a message, wrap in EIP-6492, and validate on-chain via ValidateEIP6492Offchain.
16+ // They create a Sequence wallet, sign a message, wrap in EIP-6492, and validate via
17+ // ValidateEIP6492Offchain or ValidateEIP6492Onchain. Onchain tests skip if the validator
18+ // is not deployed at EIP_6492_ADDRESS on the chain.
1619
1720func TestEIP6492Live_ValidateSequenceWalletMessage_Offchain (t * testing.T ) {
1821 // V2 counterfactual wallet on testchain
@@ -83,3 +86,54 @@ func TestEIP6492Live_ValidateDeployedSequenceWallet_Offchain(t *testing.T) {
8386 require .NoError (t , err )
8487 require .True (t , valid , "EIP-6492 offchain validation should succeed for deployed Sequence wallet" )
8588}
89+
90+ func TestEIP6492Live_ValidateSequenceWalletMessage_Onchain (t * testing.T ) {
91+ // Same as offchain test but via pre-deployed validator at EIP_6492_ADDRESS.
92+ // Skips if the validator is not deployed on this chain (e.g. Berachain testchain).
93+ wallet , err := testChain .V2DummySequenceWallet (13 , true )
94+ require .NoError (t , err )
95+
96+ message := []byte ("hello world onchain!" )
97+ _ , eip191Message := accounts .TextAndHash (message )
98+
99+ sig , err := wallet .SignMessage ([]byte (eip191Message ))
100+ require .NoError (t , err )
101+
102+ wrapped , err := sequence .EIP6492Signature (sig , wallet .GetWalletConfig ())
103+ require .NoError (t , err )
104+
105+ digest := common .BytesToHash (accounts .TextHash (message ))
106+ ctx := context .Background ()
107+
108+ valid , err := eip6492 .ValidateEIP6492Onchain (ctx , testChain .Provider , wallet .Address (), digest , wrapped , nil )
109+ if err != nil && strings .Contains (err .Error (), "returned no data" ) {
110+ t .Skipf ("EIP-6492 validator not deployed on this chain: %v" , err )
111+ }
112+ require .NoError (t , err )
113+ require .True (t , valid , "EIP-6492 onchain validation should succeed for Sequence wallet message signature" )
114+ }
115+
116+ func TestEIP6492Live_ValidateDeployedSequenceWallet_Onchain (t * testing.T ) {
117+ // Deployed wallet, validated via onchain contract. Skips if validator not deployed.
118+ wallet , err := testChain .V2DummySequenceWallet (14 , false )
119+ require .NoError (t , err )
120+
121+ message := []byte ("deployed wallet onchain sign" )
122+ _ , eip191Message := accounts .TextAndHash (message )
123+
124+ sig , err := wallet .SignMessage ([]byte (eip191Message ))
125+ require .NoError (t , err )
126+
127+ wrapped , err := sequence .EIP6492Signature (sig , wallet .GetWalletConfig ())
128+ require .NoError (t , err )
129+
130+ digest := common .BytesToHash (accounts .TextHash (message ))
131+ ctx := context .Background ()
132+
133+ valid , err := eip6492 .ValidateEIP6492Onchain (ctx , testChain .Provider , wallet .Address (), digest , wrapped , nil )
134+ if err != nil && strings .Contains (err .Error (), "returned no data" ) {
135+ t .Skipf ("EIP-6492 validator not deployed on this chain: %v" , err )
136+ }
137+ require .NoError (t , err )
138+ require .True (t , valid , "EIP-6492 onchain validation should succeed for deployed Sequence wallet" )
139+ }
0 commit comments