Skip to content

Commit

Permalink
test: add environment/node.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jan 27, 2022
1 parent 9f2f22a commit c45a6f8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/environment/node.mjs
Original file line number Diff line number Diff line change
@@ -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)
})()

0 comments on commit c45a6f8

Please sign in to comment.