Skip to content

Commit

Permalink
Populate account with a max necessary amount for all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jun 21, 2020
1 parent 59d33bf commit 0c27318
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 28 deletions.
2 changes: 1 addition & 1 deletion docker/accounts_test.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi": 100000000000001000000000000000000000
"ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi": 100000000000000000000000000000000000
}
4 changes: 1 addition & 3 deletions test/integration/aens.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { describe, it, before } from 'mocha'
import { plan, getSdk } from './'
import { getSdk } from './'
import * as R from 'ramda'
import { generateKeyPair } from '../../es/utils/crypto'
import { buildContractId, classify, computeAuctionEndBlock, computeBidFee } from '../../es/tx/builder/helpers'
Expand All @@ -35,8 +35,6 @@ function randomString (len, charSet) {
return randomString
}

plan('99000000000000000000000000')

describe('Aens', function () {
let aens
const account = generateKeyPair()
Expand Down
4 changes: 1 addition & 3 deletions test/integration/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { describe, it, before, after, beforeEach, afterEach } from 'mocha'
import * as sinon from 'sinon'
import BigNumber from 'bignumber.js'
import { getSdk, plan, BaseAe, networkId } from './'
import { getSdk, BaseAe, networkId } from './'
import { generateKeyPair, encodeBase64Check } from '../../es/utils/crypto'
import { unpackTx, buildTx, buildTxHash } from '../../es/tx/builder'
import { decode } from '../../es/tx/builder/helpers'
Expand All @@ -27,8 +27,6 @@ import MemoryAccount from '../../es/account/memory'

const wsUrl = process.env.TEST_WS_URL || 'ws://localhost:3014/channel'

plan(BigNumber('10000e18').toString())

const identityContract = `
contract Identity =
entrypoint main(x : int) : int = x
Expand Down
6 changes: 2 additions & 4 deletions test/integration/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
*/
import Compiler from '../../es/contract/compiler'
import { describe, it, before } from 'mocha'
import { BaseAe, plan, getSdk, compilerUrl } from './'
import { BaseAe, getSdk, compilerUrl } from './'
import { decode } from '../../es/tx/builder/helpers'

import * as R from 'ramda'
import { randomName } from './aens'
import { decodeEvents, readType, SOPHIA_TYPES } from '../../es/contract/aci/transformation'
Expand Down Expand Up @@ -182,14 +181,13 @@ const filesystem = {
testLib: libContract
}

plan('1000000000000000000000000')
describe('Contract', function () {
let contract
let bytecode
let deployed

before(async function () {
contract = await getSdk(true)
contract = await getSdk()
})
describe('Aens and Oracle operation delegation', () => {
let cInstance
Expand Down
19 changes: 5 additions & 14 deletions test/integration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

import { Universal, Crypto, MemoryAccount, Node } from '../../es'
import BigNumber from 'bignumber.js'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'

Expand All @@ -39,22 +38,14 @@ export const BaseAe = async (params) => Universal.waitMined(true).compose({
nodes: [{ name: 'test', instance: await Node({ url, internalUrl }) }]
})

let planned = BigNumber(0)
let charged = false

export function plan (amount) {
planned = planned.plus(amount)
}

export async function getSdk (nativeMode = true) {
const spendPromise = (async () => {
const ae = await BaseAe({ networkId })
await ae.awaitHeight(2)
await ae.spend('1' + '0'.repeat(26), account.publicKey)
})()

if (!charged && planned > 0) {
console.log(`Charging new wallet ${account.publicKey} with ${planned}`)
await ae.spend(planned.toString(10), account.publicKey)
charged = true
}
export async function getSdk (nativeMode) {
await spendPromise

return BaseAe({
accounts: [MemoryAccount({ keypair: account })],
Expand Down
4 changes: 1 addition & 3 deletions test/integration/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
*/

import { describe, it, before } from 'mocha'
import { plan, getSdk } from './'
import { getSdk } from './'
import { encodeBase64Check } from '../../es/utils/crypto'

plan('100000000000000000000')

describe('Oracle', function () {
let client
let oracle
Expand Down

0 comments on commit 0c27318

Please sign in to comment.