Skip to content

Commit

Permalink
wip: more faucet testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rh0delta committed Jul 30, 2024
1 parent 7672e9a commit f78695a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/flows/manage-accounts/new-account.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import inquirer from 'inquirer'
import { randomAsHex } from '@polkadot/util-crypto'
import { importQuestions } from './helpers/import-account'
import { importQuestions } from './utils/import-account'
// import * as passwordFlow from '../password'
import { print } from '../../common/utils'
import { createAccount } from './helpers/create-account'
import { createAccount } from './utils/create-account'
import { EntropyLogger } from 'src/common/logger'

export async function newAccount ({ accounts }, logger: EntropyLogger) {
Expand Down
16 changes: 13 additions & 3 deletions tests/faucet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ test('Faucet Tests', async t => {
max_transfer_amount: 10_000_000_000,
genesis_hash: stripHexPrefix(genesisHash.toString())
}
const configurationSchema = {
max_transfer_amount: "number",
genesis_hash: "string"
}
const auxDataSchema = {
amount: "number",
string_account_id: "string",
spec_version: "number",
transaction_version: "number",
}
console.log('userconfig', userConfig);

// Convert JSON string to bytes and then to hex
Expand All @@ -31,17 +41,17 @@ test('Faucet Tests', async t => {
console.log('program config', programConfig);

// Deploy faucet program
const faucetProgramPointer = await run('Deploy faucet program', entropy.programs.dev.deploy(faucetProgram, programConfig))
const faucetProgramPointer = await run('Deploy faucet program', entropy.programs.dev.deploy(faucetProgram, configurationSchema, auxDataSchema))
console.log('pointer', faucetProgramPointer);

let naynayBalance = await getBalance(naynayEntropy, naynayEntropy.keyring.accounts.registration.address)
t.equal(naynayBalance, 0, 'Naynay is broke af')
// register with faucet program
await run('Register faucet program for charlie stash', register(
await run('Register Faucet Program for charlie stash', register(
entropy,
{
programModAddress: entropy.keyring.accounts.registration.address,
programData: [{ program_pointer: faucetProgramPointer, program_config: programConfig }]
programData: [{ program_pointer: faucetProgramPointer, program_config: userConfig }]
}
))

Expand Down
2 changes: 1 addition & 1 deletion tests/manage-accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import test from 'tape'
import { spinNetworkUp, spinNetworkDown, } from "@entropyxyz/sdk/testing"
import { EntropyAccountConfig, EntropyConfig } from 'src/config/types'
import { listAccounts } from 'src/flows/manage-accounts/list'
import { createAccount } from 'src/flows/manage-accounts/helpers/create-account'
import { createAccount } from 'src/flows/manage-accounts/utils/create-account'
import * as config from 'src/config'
import { promiseRunner, sleep } from './testing-utils'
import { charlieStashAddress, charlieStashSeed } from './testing-utils/constants'
Expand Down
3 changes: 2 additions & 1 deletion tests/testing-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export function promiseRunner(t: any, keepThrowing = false) {
return promise
.then((result) => {
const time = (Date.now() - startTime) / 1000
const pad = Array(40 - message.length)
const noPad = message.length > 40
const pad = noPad ? '' : Array(40 - message.length)
.fill('-')
.join('')
t.pass(`${message} ${pad} ${time}s`)
Expand Down

0 comments on commit f78695a

Please sign in to comment.