|
| 1 | +import expect from 'expect'; |
| 2 | +import { weight, createConnection, deploy, transaction, aliceKeypair, query, } from './index'; |
| 3 | +import { ContractPromise } from '@polkadot/api-contract'; |
| 4 | +import { ApiPromise } from '@polkadot/api'; |
| 5 | +import { KeyringPair } from '@polkadot/keyring/types'; |
| 6 | + |
| 7 | +describe('Test cross contract calls between ink and solidity', () => { |
| 8 | + let conn: ApiPromise; |
| 9 | + let alice: KeyringPair; |
| 10 | + |
| 11 | + let ink_contract: ContractPromise; |
| 12 | + |
| 13 | + let sol_contract: ContractPromise; |
| 14 | + let inkee_echo = [1, 2, 3, 4]; |
| 15 | + |
| 16 | + before(async function () { |
| 17 | + conn = await createConnection(); |
| 18 | + alice = aliceKeypair(); |
| 19 | + |
| 20 | + let ink_deployment = await deploy(conn, alice, 'ink/caller/target/ink/caller.contract', 0n); |
| 21 | + ink_contract = new ContractPromise(conn, ink_deployment.abi, ink_deployment.address); |
| 22 | + |
| 23 | + let sol_deployment = await deploy(conn, alice, 'Inkee.contract', 0n); |
| 24 | + sol_contract = new ContractPromise(conn, sol_deployment.abi, sol_deployment.address); |
| 25 | + }); |
| 26 | + |
| 27 | + it('calls solidity from ink', async function () { |
| 28 | + this.timeout(50000); |
| 29 | + |
| 30 | + async function proxy(goes_in: number) { |
| 31 | + const comes_out = await query(conn, alice, ink_contract, "u32_proxy", [sol_contract.address, inkee_echo, goes_in, null, null]); |
| 32 | + expect(comes_out.output?.toJSON()).toEqual({ "ok": goes_in }); |
| 33 | + } |
| 34 | + |
| 35 | + await proxy(0); |
| 36 | + await proxy(1); |
| 37 | + await proxy(1337); |
| 38 | + await proxy(0xffffffff); |
| 39 | + }); |
| 40 | + |
| 41 | + after(async function () { |
| 42 | + await conn.disconnect(); |
| 43 | + }); |
| 44 | +}); |
0 commit comments