Skip to content

Commit

Permalink
test: fix environment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jun 17, 2022
1 parent a7ef9f1 commit 4290876
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/ae/aens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { commitmentHash, isAuctionName, Pointer } from '../tx/builder/helpers'
import { CLIENT_TTL, NAME_TTL, TX_TYPE, AensName } from '../tx/builder/schema'
import { ArgumentError } from '../utils/errors'
import { EncodedData } from '../utils/encoder'
import { BigNumber } from 'bignumber.js'
import BigNumber from 'bignumber.js'
import { send } from './spend'
import { getName, height } from '../chain'
import { _buildTx, BuildTxOptions } from '../tx'
Expand Down
2 changes: 1 addition & 1 deletion src/tx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import {
ArgumentError, UnsupportedProtocolError, UnknownTxError, InvalidTxParamsError
} from '../utils/errors'
import { BigNumber } from 'bignumber.js'
import BigNumber from 'bignumber.js'
import Node from '../node'
import { EncodedData } from '../utils/encoder'
import { buildTx as syncBuildTx, unpackTx } from './builder/index'
Expand Down
32 changes: 16 additions & 16 deletions test/environment/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@
Open developer console
<script src="../../dist/aepp-sdk.browser-script.js"></script>
<script type="text/javascript">
const { Node, Universal, MemoryAccount } = Ae
const { Node, AeSdk, MemoryAccount } = Ae

const contractSource = `
contract Test =
entrypoint getArg(x : map(string, int)) = x
`;
`
const node = new Node('https://testnet.aeternity.io')
const aeSdk = new AeSdk({
nodes: [{ name: 'testnet', instance: node }],
compilerUrl: 'https://compiler.aepps.com'
});

(async () => {
const node = new Node('https://testnet.aeternity.io')
const sdk = await Universal({
nodes: [{ name: 'testnet', instance: node }],
compilerUrl: 'https://compiler.aepps.com',
accounts: [new MemoryAccount({
keypair: {
publicKey: 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR',
secretKey: 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b'
}
})]
})
await aeSdk.addAccount(new MemoryAccount({
keypair: {
publicKey: 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR',
secretKey: 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b'
}
}), { select: true })

console.log('Height:', await sdk.height())
console.log('Instanceof works correctly for nodes pool', sdk.pool instanceof Map)
console.log('Height:', await aeSdk.height())
console.log('Instanceof works correctly for nodes pool', aeSdk.pool instanceof Map)

const contract = await sdk.getContractInstance({ source: contractSource })
const contract = await aeSdk.getContractInstance({ source: contractSource })
const deployInfo = await contract.deploy()
console.log('Contract deployed at', deployInfo.address)
const map = new Map([['foo', 42], ['bar', 43]])
Expand Down
26 changes: 13 additions & 13 deletions test/environment/node.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const { Node, Universal, MemoryAccount } = require('../../dist/aepp-sdk')
const { Node, AeSdk, MemoryAccount } = require('../../dist/aepp-sdk')

const contractSource = `
contract Test =
entrypoint getArg(x : map(string, int)) = x
`;
`
const node = new Node('https://testnet.aeternity.io')
const aeSdk = new AeSdk({
nodes: [{ name: 'testnet', instance: node }],
compilerUrl: 'https://compiler.aepps.com'
});

(async () => {
const node = new Node('https://testnet.aeternity.io')
const aeSdk = await Universal({
nodes: [{ name: 'testnet', instance: node }],
compilerUrl: 'https://compiler.aepps.com',
accounts: [new MemoryAccount({
keypair: {
publicKey: 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR',
secretKey: 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b'
}
})]
})
await aeSdk.addAccount(new MemoryAccount({
keypair: {
publicKey: 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR',
secretKey: 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b'
}
}), { select: true })

console.log('Height:', await aeSdk.height())
console.log('Instanceof works correctly for nodes pool', aeSdk.pool instanceof Map)
Expand Down
26 changes: 13 additions & 13 deletions test/environment/node.mjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { Node, Universal, MemoryAccount } from '../../es/index.mjs'
import { Node, AeSdk, MemoryAccount } from '../../es/index.mjs'

const contractSource = `
contract Test =
entrypoint getArg(x : map(string, int)) = x
`;
`
const node = new Node('https://testnet.aeternity.io')
const aeSdk = new AeSdk({
nodes: [{ name: 'testnet', instance: node }],
compilerUrl: 'https://compiler.aepps.com'
});

(async () => {
const node = new Node('https://testnet.aeternity.io')
const aeSdk = await Universal({
nodes: [{ name: 'testnet', instance: node }],
compilerUrl: 'https://compiler.aepps.com',
accounts: [new MemoryAccount({
keypair: {
publicKey: 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR',
secretKey: 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b'
}
})]
})
await aeSdk.addAccount(new MemoryAccount({
keypair: {
publicKey: 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR',
secretKey: 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b'
}
}), { select: true })

console.log('Height:', await aeSdk.height())
console.log('Instanceof works correctly for nodes pool', aeSdk.pool instanceof Map)
Expand Down

0 comments on commit 4290876

Please sign in to comment.