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