@ -2,16 +2,19 @@ const { strict: assert } = require('assert');
const { convertToHexValue , withFixtures } = require ( '../helpers' ) ;
describe ( 'Chain Interactions' , function ( ) {
it ( 'should add the XDAI chain and not switch the network' , async function ( ) {
const ganacheOptions = {
accounts : [
{
secretKey :
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC' ,
balance : convertToHexValue ( 25000000000000000000 ) ,
} ,
] ,
} ;
const port = 8546 ;
const chainId = 1338 ;
const ganacheOptions = {
accounts : [
{
secretKey :
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC' ,
balance : convertToHexValue ( 25000000000000000000 ) ,
} ,
] ,
concurrent : { port , chainId } ,
} ;
it ( 'should add the Ganache test chain and not switch the network' , async function ( ) {
await withFixtures (
{
dapp : true ,
@ -36,12 +39,14 @@ describe('Chain Interactions', function () {
) ;
// verify chain details
const [ networkName , networkUrl , chainId ] = await driver . findElements (
'.definition-list dd' ,
) ;
assert . equal ( await networkName . getText ( ) , 'xDAI Chain' ) ;
assert . equal ( await networkUrl . getText ( ) , 'https://dai.poa.network' ) ;
assert . equal ( await chainId . getText ( ) , '100' ) ;
const [
networkName ,
networkUrl ,
chainIdElement ,
] = await driver . findElements ( '.definition-list dd' ) ;
assert . equal ( await networkName . getText ( ) , ` Localhost ${ port } ` ) ;
assert . equal ( await networkUrl . getText ( ) , ` http://127.0.0.1: ${ port } ` ) ;
assert . equal ( await chainIdElement . getText ( ) , chainId . toString ( ) ) ;
// approve add chain, cancel switch chain
await driver . clickElement ( { text : 'Approve' , tag : 'button' } ) ;
@ -55,25 +60,16 @@ describe('Chain Interactions', function () {
const networkDisplay = await driver . findElement ( '.network-display' ) ;
await networkDisplay . click ( ) ;
assert . equal ( await networkDisplay . getText ( ) , 'Localhost 8545' ) ;
const xDai Chain = await driver . findElements ( {
text : 'xDAI Chain' ,
const ganache Chain = await driver . findElements ( {
text : ` Localhost ${ port } ` ,
tag : 'span' ,
} ) ;
assert . ok ( xDai Chain. length , 1 ) ;
assert . ok ( ganache Chain. length , 1 ) ;
} ,
) ;
} ) ;
it ( 'should add the XDAI chain and switch the network' , async function ( ) {
const ganacheOptions = {
accounts : [
{
secretKey :
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC' ,
balance : convertToHexValue ( 25000000000000000000 ) ,
} ,
] ,
} ;
it ( 'should add the Ganache chain and switch the network' , async function ( ) {
await withFixtures (
{
dapp : true ,
@ -107,7 +103,7 @@ describe('Chain Interactions', function () {
// verify current network
const networkDisplay = await driver . findElement ( '.network-display' ) ;
assert . equal ( await networkDisplay . getText ( ) , 'xDAI Chain' ) ;
assert . equal ( await networkDisplay . getText ( ) , ` Localhost ${ port } ` ) ;
} ,
) ;
} ) ;