@@ -52,41 +52,41 @@ describe("chains", () => {
52
52
expect ( chain ) . to . deep . equal ( chains . foundry ) ;
53
53
} ) ;
54
54
55
- it ( "should throw if the chain id is 31337 and the network is neither hardhat nor foundry " , async ( ) => {
55
+ it ( "should return the first matching chain if the chain id is not 31337 and there are multiple chains with that id " , async ( ) => {
56
56
const provider : EthereumProvider = new EthereumMockedProvider ( ) ;
57
57
const sendStub = sinon . stub ( provider , "send" ) ;
58
- sendStub . withArgs ( "eth_chainId" ) . returns ( Promise . resolve ( "0x7a69" ) ) ; // 31337 in hex
58
+ // chain id 999 corresponds to wanchainTestnet but also zoraTestnet
59
+ sendStub . withArgs ( "eth_chainId" ) . returns ( Promise . resolve ( "0x3e7" ) ) ;
59
60
sendStub . withArgs ( "hardhat_metadata" ) . throws ( ) ;
60
61
sendStub . withArgs ( "anvil_nodeInfo" ) . throws ( ) ;
61
62
62
- await expect ( getChain ( provider ) ) . to . be . rejectedWith (
63
- `The chain id corresponds to a development network but we couldn't detect which one.
64
- Please report this issue if you're using Hardhat or Foundry.`
65
- ) ;
63
+ const chain = await getChain ( provider ) ;
64
+
65
+ expect ( chain ) . to . deep . equal ( chains . wanchainTestnet ) ;
66
66
} ) ;
67
67
68
- it ( "should throw if the chain id is not 31337 and there is no chain with that id " , async ( ) => {
68
+ it ( "should throw if the chain id is 31337 and the network is neither hardhat nor foundry " , async ( ) => {
69
69
const provider : EthereumProvider = new EthereumMockedProvider ( ) ;
70
70
const sendStub = sinon . stub ( provider , "send" ) ;
71
- sendStub . withArgs ( "eth_chainId" ) . returns ( Promise . resolve ( "0x0 " ) ) ; // fake chain id 0
71
+ sendStub . withArgs ( "eth_chainId" ) . returns ( Promise . resolve ( "0x7a69 " ) ) ; // 31337 in hex
72
72
sendStub . withArgs ( "hardhat_metadata" ) . throws ( ) ;
73
73
sendStub . withArgs ( "anvil_nodeInfo" ) . throws ( ) ;
74
74
75
75
await expect ( getChain ( provider ) ) . to . be . rejectedWith (
76
- / N o n e t w o r k w i t h c h a i n i d 0 f o u n d /
76
+ `The chain id corresponds to a development network but we couldn't detect which one.
77
+ Please report this issue if you're using Hardhat or Foundry.`
77
78
) ;
78
79
} ) ;
79
80
80
- it ( "should throw if the chain id is not 31337 and there are multiple chains with that id" , async ( ) => {
81
+ it ( "should throw if the chain id is not 31337 and there is no chain with that id" , async ( ) => {
81
82
const provider : EthereumProvider = new EthereumMockedProvider ( ) ;
82
83
const sendStub = sinon . stub ( provider , "send" ) ;
83
- // chain id 999 corresponds to Wanchain Testnet but also Zora Goerli Testnet
84
- sendStub . withArgs ( "eth_chainId" ) . returns ( Promise . resolve ( "0x3e7" ) ) ;
84
+ sendStub . withArgs ( "eth_chainId" ) . returns ( Promise . resolve ( "0x0" ) ) ; // fake chain id 0
85
85
sendStub . withArgs ( "hardhat_metadata" ) . throws ( ) ;
86
86
sendStub . withArgs ( "anvil_nodeInfo" ) . throws ( ) ;
87
87
88
88
await expect ( getChain ( provider ) ) . to . be . rejectedWith (
89
- / M u l t i p l e n e t w o r k s w i t h c h a i n i d 9 9 9 f o u n d . /
89
+ / N o n e t w o r k w i t h c h a i n i d 0 f o u n d /
90
90
) ;
91
91
} ) ;
92
92
} ) ;
0 commit comments