From c45a6f87f1e39bbd3fa7f514523409cc041c1882 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Wed, 26 Jan 2022 13:40:41 +0300 Subject: [PATCH] test: add environment/node.mjs --- test/environment/node.mjs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/environment/node.mjs diff --git a/test/environment/node.mjs b/test/environment/node.mjs new file mode 100644 index 0000000000..d400b3f749 --- /dev/null +++ b/test/environment/node.mjs @@ -0,0 +1,31 @@ +import { Node, Universal, MemoryAccount } from '../../es/index.mjs' + +const contractSource = ` +contract Test = + entrypoint getArg(x : map(string, int)) = x +`; + +(async () => { + const node = await Node({ url: 'https://testnet.aeternity.io' }) + const sdk = await Universal({ + nodes: [{ name: 'testnet', instance: node }], + compilerUrl: 'https://compiler.aepps.com', + accounts: [MemoryAccount({ + keypair: { + publicKey: 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR', + secretKey: 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b' + } + })] + }) + + console.log('Height:', await sdk.height()) + console.log('Instanceof works correctly for nodes pool', sdk.pool instanceof Map) + + const contract = await sdk.getContractInstance({ source: contractSource }) + const deployInfo = await contract.deploy() + console.log('Contract deployed at', deployInfo.address) + const map = new Map([['foo', 42], ['bar', 43]]) + const { decodedResult } = await contract.methods.getArg(map) + console.log('Call result', decodedResult) + console.log('Instanceof works correctly for returned map', decodedResult instanceof Map) +})()