1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import { Universal, Crypto, MemoryAccount, Node } from '../../es'
|
19 | import chai from 'chai'
|
20 | import chaiAsPromised from 'chai-as-promised'
|
21 |
|
22 | chai.use(chaiAsPromised)
|
23 | chai.should()
|
24 |
|
25 | export const url = process.env.TEST_URL || 'http://localhost:3013'
|
26 | export const internalUrl = process.env.TEST_INTERNAL_URL || 'http://localhost:3113'
|
27 | export const compilerUrl = process.env.COMPILER_URL || 'http://localhost:3080'
|
28 | export const publicKey = process.env.PUBLIC_KEY || 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR'
|
29 | const secretKey = process.env.SECRET_KEY || 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b'
|
30 | export const networkId = process.env.TEST_NETWORK_ID || 'ae_devnet'
|
31 | const forceCompatibility = process.env.FORCE_COMPATIBILITY || false
|
32 | export const genesisAccount = MemoryAccount({ keypair: { publicKey, secretKey } })
|
33 | export const account = Crypto.generateKeyPair()
|
34 |
|
35 | export const BaseAe = async (params = {}) => {
|
36 | const ae = await Universal.waitMined(true).compose({
|
37 | deepProps: { Swagger: { defaults: { debug: !!process.env.DEBUG } } },
|
38 | props: { process, compilerUrl }
|
39 | })({
|
40 | ...params,
|
41 | forceCompatibility,
|
42 | accounts: [...params.accounts || [], genesisAccount],
|
43 | nodes: [{ name: 'test', instance: await Node({ url, internalUrl }) }]
|
44 | })
|
45 | ae.removeAccount(process.env.WALLET_PUB)
|
46 | return ae
|
47 | }
|
48 |
|
49 | const spendPromise = (async () => {
|
50 | const ae = await BaseAe({ networkId })
|
51 | await ae.awaitHeight(2)
|
52 | await ae.spend('1' + '0'.repeat(26), account.publicKey)
|
53 | })()
|
54 |
|
55 | export async function getSdk (nativeMode) {
|
56 | await spendPromise
|
57 |
|
58 | return BaseAe({
|
59 | accounts: [MemoryAccount({ keypair: account })],
|
60 | address: account.publicKey,
|
61 | nativeMode,
|
62 | networkId
|
63 | })
|
64 | }
|