1- import { assert , expect } from 'chai' ;
2- import { step } from 'mocha-steps' ;
3- import { signAndSend , describeLitentry , loadConfig , sudoWrapperTc } from '../common/utils' ;
1+ import { expect , test } from 'vitest' ;
2+ import { signAndSend , describeLitentry , loadConfig , sudoWrapperTc } from '../common/utils/index.js' ;
43import { compiled } from '../common/utils/compile' ;
54import { evmToAddress } from '@polkadot/util-crypto' ;
65import { hexToU8a , u8aToHex } from '@polkadot/util' ;
@@ -16,12 +15,12 @@ describeLitentry('Test EVM Module Contract', ``, (context) => {
1615 mappedAddress : evmToAddress ( '0xaaafB3972B05630fCceE866eC69CdADd9baC2771' , 31 ) ,
1716 } ;
1817
19- step ( 'Set ExtrinsicFilter mode to Test' , async function ( ) {
18+ test ( 'Set ExtrinsicFilter mode to Test' , async ( ) => {
2019 let extrinsic = await sudoWrapperTc ( context . api , context . api . tx . extrinsicFilter . setMode ( 'Test' ) ) ;
2120 await signAndSend ( extrinsic , context . alice ) ;
2221 } ) ;
2322
24- step ( 'Transfer Value from Eve to EVM external account' , async function ( ) {
23+ test ( 'Transfer Value from Eve to EVM external account' , async ( ) => {
2524 let eveMappedEVMAccount = context . eve . publicKey . slice ( 0 , 20 ) ;
2625 let eveMappedSustrateAccount = evmToAddress ( eveMappedEVMAccount , 31 ) ;
2726
@@ -58,13 +57,11 @@ describeLitentry('Test EVM Module Contract', ``, (context) => {
5857 // If a substrate account using pallet_evm to trigger evm transaction,
5958 // it will bump 2 for nonce (one for substrate extrinsic, one for evm).
6059 // +1 nonce for original substrate account, plus another 1 nonce for original substrate account's truncated evm address's mapped susbtrate account.
61- expect ( eveCurrentNonce . toNumber ( ) ) . to . equal ( eveInitNonce . toNumber ( ) + 1 ) ;
62- expect ( evmAccountCurrentBalance . free . toBigInt ( ) ) . to . equal (
63- evmAccountInitBalance . free . toBigInt ( ) + BigInt ( value )
64- ) ;
60+ expect ( eveCurrentNonce . toNumber ( ) ) . toBe ( eveInitNonce . toNumber ( ) + 1 ) ;
61+ expect ( evmAccountCurrentBalance . free . toBigInt ( ) ) . toBe ( evmAccountInitBalance . free . toBigInt ( ) + BigInt ( value ) ) ;
6562 } ) ;
6663
67- step ( 'Transfer some value back to Eve Mapped account from EVM external account' , async function ( ) {
64+ test ( 'Transfer some value back to Eve Mapped account from EVM external account' , async ( ) => {
6865 // Get the initial balance of Eve and EVM external account
6966 let eveMappedEVMAccount = context . eve . publicKey . slice ( 0 , 20 ) ;
7067 let eveMappedSustrateAccount = evmToAddress ( eveMappedEVMAccount , 31 ) ;
@@ -99,11 +96,11 @@ describeLitentry('Test EVM Module Contract', ``, (context) => {
9996
10097 console . log ( `evmAccount Balance: ${ evmAccountCurrentBalance } ` ) ;
10198
102- expect ( evmAccountCurrentNonce . toNumber ( ) ) . to . equal ( evmAccountInitNonce . toNumber ( ) + 1 ) ;
103- expect ( eveCurrentBalance . free . toBigInt ( ) ) . to . equal ( eveInitBalance . free . toBigInt ( ) + BigInt ( value ) ) ;
99+ expect ( evmAccountCurrentNonce . toNumber ( ) ) . toBe ( evmAccountInitNonce . toNumber ( ) + 1 ) ;
100+ expect ( eveCurrentBalance . free . toBigInt ( ) ) . toBe ( eveInitBalance . free . toBigInt ( ) + BigInt ( value ) ) ;
104101 } ) ;
105102
106- step ( 'Test substrate signature can not access ultra vires evm/substrate account' , async function ( ) {
103+ test ( 'Test substrate signature can not access ultra vires evm/substrate account' , async ( ) => {
107104 // Get the initial balance of Eve and EVM external account
108105 const eveInitNonce = ( await context . api . query . system . account ( context . eve . address ) ) . nonce ;
109106 const evmAccountInitBalance = ( await context . api . query . system . account ( evmAccountRaw . mappedAddress ) ) . data ;
@@ -130,12 +127,12 @@ describeLitentry('Test EVM Module Contract', ``, (context) => {
130127
131128 // Extrinsic succeed with failed origin
132129 // So the evm transaction nonce bump will not be triggered
133- expect ( eveCurrentNonce . toNumber ( ) ) . to . equal ( eveInitNonce . toNumber ( ) + 1 ) ;
130+ expect ( eveCurrentNonce . toNumber ( ) ) . toBe ( eveInitNonce . toNumber ( ) + 1 ) ;
134131 // Which means balance unchanged
135- expect ( evmAccountCurrentBalance . free . toBigInt ( ) ) . to . equal ( evmAccountInitBalance . free . toBigInt ( ) ) ;
132+ expect ( evmAccountCurrentBalance . free . toBigInt ( ) ) . toBe ( evmAccountInitBalance . free . toBigInt ( ) ) ;
136133 } ) ;
137134
138- step ( 'Deploy and test contract by EVM external account' , async function ( ) {
135+ test ( 'Deploy and test contract by EVM external account' , async ( ) => {
139136 // Get the bytecode and API
140137 const bytecode = compiled . evm . bytecode . object ;
141138 const abi = compiled . abi ;
@@ -183,8 +180,7 @@ describeLitentry('Test EVM Module Contract', ``, (context) => {
183180 } ;
184181
185182 const message = await sayMessage ( deployed . contractAddress ! ) ;
186- const initialResult = message === 'Hello World' ? 1 : 0 ;
187- assert . equal ( 1 , initialResult , 'Contract initial storage query mismatch' ) ;
183+ expect ( message ) . toBe ( 'Hello World' ) ;
188184
189185 // Test set message contract method
190186 const setMessage = async ( contractAddress : string , accountFrom : any , message : string ) => {
@@ -209,11 +205,10 @@ describeLitentry('Test EVM Module Contract', ``, (context) => {
209205 } ;
210206 const setMsg = await setMessage ( deployed . contractAddress ! , evmAccountRaw , 'Goodbye World' ) ;
211207 const sayMsg = await sayMessage ( deployed . contractAddress ! ) ;
212- const setResult = sayMsg === 'Goodbye World' ? 1 : 0 ;
213- assert . equal ( 1 , setResult , 'Contract modified storage query mismatch' ) ;
208+ expect ( sayMsg ) . toBe ( 'Goodbye World' ) ;
214209 } ) ;
215210
216- step ( 'Set ExtrinsicFilter mode to Normal' , async function ( ) {
211+ test ( 'Set ExtrinsicFilter mode to Normal' , async ( ) => {
217212 let extrinsic = await sudoWrapperTc ( context . api , context . api . tx . extrinsicFilter . setMode ( 'Normal' ) ) ;
218213 await signAndSend ( extrinsic , context . alice ) ;
219214 } ) ;
0 commit comments