Skip to content

Commit

Permalink
slim down the logging and charlies balance cant be trusted
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiebee committed Oct 19, 2024
1 parent 1914c31 commit 8ba3785
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
17 changes: 10 additions & 7 deletions dev/testing-utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async function isWebSocketReady (endpoint) {
}

export async function jumpStartNetwork (entropy, maxTime = 360 * SECONDS) {
console.log('jumping')
let timeout, unsub
// if you used spinNetworkUp check what network was used
// this is done this way so we can still use this for other
Expand All @@ -88,7 +89,6 @@ export async function jumpStartNetwork (entropy, maxTime = 360 * SECONDS) {
if (!startHeader) startHeader = header
if (started) {
headersSenseStart++
if (lastEventTime) console.log('context#headers time sense last events seen:', Math.floor((Date.now() - lastEventTime)/1000), 'seconds')

}
if (
Expand All @@ -103,10 +103,9 @@ export async function jumpStartNetwork (entropy, maxTime = 360 * SECONDS) {
) {
await entropy.substrate.tx.registry.jumpStartNetwork()
.signAndSend(entropy.keyring.accounts.registration.pair)
console.log('retrying jumpstart', headersSenseStart, 'headers sense initial try')
console.log('had to tell everyone to jump again')
}

console.log(`#${header.number}: ${header.author}`);
if (headersSenseStart === 200) {
reject('waiting period of 200 blocks sense initial jump start reached')
blockUnsub()
Expand All @@ -115,24 +114,28 @@ export async function jumpStartNetwork (entropy, maxTime = 360 * SECONDS) {
})
unsub = await entropy.substrate.query.system.events((records) => {
const nowEvents = Date.now()
if (lastEventTime) console.log('context#events time sense last events:', Math.floor((nowEvents - lastEventTime)/1000), 'seconds')
lastEventTime = nowEvents
console.log('time sense start:', Math.floor((Date.now() - startTime)/1000), 'seconds')
console.log('event methods:', records.map((record) => record?.event?.method))
if (records.find(record => record?.event?.method === wantedMethod)) {
unsub()
blockUnsub()
res(undefined)
} else if (records.find(record => record?.event?.method === 'StartedNetworkJumpStart')) {
started = true
console.log('everyone knows to start jumping')
}
})
})

await entropy.substrate.tx.registry.jumpStartNetwork()
.signAndSend(entropy.keyring.accounts.registration.pair)

await isDone.catch((err) => {console.error(err); process.exit(1)})
return isDone.then(() => {
console.log(`
final report:jump-start
total-time: ${Math.floor((Date.now() - startTime)/1000)} seconds
total-block-time: ${headersSenseStart} blocks
`)
}).catch((err) => {console.error(err); process.exit(1)})
}

export async function spinNetworkDown (networkType = 'four-nodes') {
Expand Down
12 changes: 0 additions & 12 deletions tests/transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,6 @@ test('Transfer', async (t) => {
'initially naynay has nothing'
)
}
{
const account = charlie.keyring.accounts.registration.address
const accountInfo = (await charlie.substrate.query.system.account(
account
)) as any
t.equal(
BigInt(accountInfo.data.free),
BigInt(1e17),
'initially charlie is rich!'
)
}

const sender = charlie.keyring.accounts.registration.pair
function sendMoney(amount) {
return new Promise(async (resolve, reject) => {
Expand Down

0 comments on commit 8ba3785

Please sign in to comment.