difftreelog
test evm payable
in: master
3 files changed
tests/src/eth/payable.test.tsdiffbeforeafterbothno changes
tests/src/eth/util/helpers.tsdiffbeforeafterboth197 return flipper;197 return flipper;198}198}199199200export async function deployCollector(web3: Web3 & Web3HttpMarker, deployer: string) {200export async function deployCollector(web3: Web3, deployer: string) {201 const compiled = compileContract('Collector', `201 const compiled = compileContract('Collector', `202 contract Collector {202 contract Collector {203 uint256 collected;203 uint256 collected;204 function giveMoney() public payable {204 fallback() external payable {205 collected += msg.value;205 giveMoney();206 }206 }207 function getCollected() public view returns (uint256) {207 function giveMoney() public payable {208 return collected;208 collected += msg.value;209 }209 }210 }210 function getCollected() public view returns (uint256) {211 return collected;212 }213 function getUnaccounted() public view returns (uint256) {214 return address(this).balance - collected;215 }216217 function withdraw(address payable target) public {218 target.transfer(collected);219 collected = 0;220 }221 }211 `);222 `);212 const Collector = new web3.eth.Contract(compiled.abi, undefined, {223 const Collector = new web3.eth.Contract(compiled.abi, undefined, {213 data: compiled.object,224 data: compiled.object,214 from: deployer,225 from: deployer,tests/src/substrate/get-balance.tsdiffbeforeafterboth6import { ApiPromise } from '@polkadot/api';6import { ApiPromise } from '@polkadot/api';7import {AccountInfo} from '@polkadot/types/interfaces/system';7import {AccountInfo} from '@polkadot/types/interfaces/system';8import promisifySubstrate from './promisify-substrate';8import promisifySubstrate from './promisify-substrate';9import { IKeyringPair } from '@polkadot/types/types';10import { submitTransactionAsync } from './substrate-api';11import { getGenericResult } from '../util/helpers';12import { expect } from 'chai';91310export default async function getBalance(api: ApiPromise, accounts: string[]): Promise<Array<bigint>> {14export default async function getBalance(api: ApiPromise, accounts: string[]): Promise<Array<bigint>> {11 const balance = promisifySubstrate(api, (acc: string[]) => api.query.system.account.multi(acc));15 const balance = promisifySubstrate(api, (acc: string[]) => api.query.system.account.multi(acc));12 const responce = await balance(accounts) as unknown as AccountInfo[];16 const responce = await balance(accounts) as unknown as AccountInfo[];13 return responce.map((r) => r.data.free.toBigInt().valueOf());17 return responce.map((r) => r.data.free.toBigInt().valueOf());14}18}151920export async function getBalanceSingle(api: ApiPromise, account: string): Promise<bigint> {21 return (await getBalance(api, [account]))[0];22}2324export async function transferBalanceExpectSuccess(api: ApiPromise, from: IKeyringPair, to: string, amount: bigint | string) {25 const tx = api.tx.balances.transfer(to, amount);26 const events = await submitTransactionAsync(from, tx);27 const result = getGenericResult(events);28 expect(result.success).to.be.true;29}