ink_cross_calls.spec.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. describe('Test cross contract calls between ink and solidity', () => {
  7. let conn: ApiPromise;
  8. let alice: KeyringPair;
  9. let ink_contract: ContractPromise;
  10. let sol_contract: ContractPromise;
  11. let inkee_echo = [1, 2, 3, 4];
  12. before(async function () {
  13. conn = await createConnection();
  14. alice = aliceKeypair();
  15. let ink_deployment = await deploy(conn, alice, 'ink/caller/target/ink/caller.contract', 0n);
  16. ink_contract = new ContractPromise(conn, ink_deployment.abi, ink_deployment.address);
  17. let sol_deployment = await deploy(conn, alice, 'Inkee.contract', 0n);
  18. sol_contract = new ContractPromise(conn, sol_deployment.abi, sol_deployment.address);
  19. });
  20. it('calls solidity from ink', async function () {
  21. this.timeout(50000);
  22. async function proxy(goes_in: number) {
  23. const comes_out = await query(conn, alice, ink_contract, "u32_proxy", [sol_contract.address, inkee_echo, goes_in, null, null]);
  24. expect(comes_out.output?.toJSON()).toEqual({ "ok": goes_in });
  25. }
  26. await proxy(0);
  27. await proxy(1);
  28. await proxy(1337);
  29. await proxy(0xffffffff);
  30. });
  31. after(async function () {
  32. await conn.disconnect();
  33. });
  34. });