overloading.spec.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-License-Identifier: Apache-2.0
  2. import expect from 'expect';
  3. import { createConnection, deploy, transaction, aliceKeypair, query, } from './index';
  4. import { ContractPromise } from '@polkadot/api-contract';
  5. import { ApiPromise } from '@polkadot/api';
  6. describe('Deploy contract with overloaded functions using mangled names', () => {
  7. let conn: ApiPromise;
  8. before(async function () {
  9. conn = await createConnection();
  10. });
  11. after(async function () {
  12. await conn.disconnect();
  13. });
  14. it('works with mangled function names', async function () {
  15. this.timeout(50000);
  16. const alice = aliceKeypair();
  17. let deploy_contract = await deploy(conn, alice, 'Overloading.contract', BigInt(0));
  18. let contract = new ContractPromise(conn, deploy_contract.abi, deploy_contract.address);
  19. let res0 = await query(conn, alice, contract, "echo");
  20. expect(res0.output?.toJSON()).toEqual(42);
  21. let res1 = await query(conn, alice, contract, "echoUint32", [1234]);
  22. expect(res1.output?.toJSON()).toEqual(1234);
  23. let someStruct = { s: "foo", e: [["v1", "v2"], ["v3", "v4"]] };
  24. let res2 = await query(conn, alice, contract, "echoBoolStringUint8Array2Array", [true, someStruct]);
  25. expect(res2.output?.toJSON()).toEqual(someStruct);
  26. });
  27. });