Skip to content

Commit

Permalink
Fix exchange test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lbqds committed Jan 4, 2024
1 parent e4a1c6e commit 232319d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/web3/src/utils/exchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('exchange', function () {
'Invalid base58 string'
)
expect(() => validateExchangeAddress('1GKWggDapVjTdU2vyna3YjVgdpnwHkKzx8FHA9gU7uoeY')).not.toThrow()
expect(() => validateExchangeAddress('1fvbFEFML2F2GZmNDHd9uafFALMG8QSwbCJHfQipw6sz')).not.toThrow()
const nodeProvider = new NodeProvider('http://127.0.0.1:22973')
for (let i = 0; i < 20; i++) {
const wallet0 = PrivateKeyWallet.Random(undefined, nodeProvider, 'default')
Expand Down
13 changes: 8 additions & 5 deletions test/exchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Exchange {
this.depositTxs.push(tx.unsigned.txId)
}

async handleBlock(block: node.BlockEntry) {
async handleBlock(block: node.BlockEntry, resolver: () => void) {
for (const tx of block.transactions) {
if (isSimpleALPHTransferTx(tx)) {
const { targetAddress, depositAmount } = getALPHDepositInfo(tx)
Expand All @@ -214,13 +214,16 @@ class Exchange {
}
}
}
resolver()
}

async startPolling(): Promise<void> {
this.eventEmitter.on('block', (block) => this.handleBlock(block))
const callback = (block: node.BlockEntry) => {
this.eventEmitter.emit('block', block)
return Promise.resolve()
this.eventEmitter.on('block', ([block, resolver]) => this.handleBlock(block, resolver))
const callback = async (block: node.BlockEntry) => {
let resolver: any
const promise = new Promise<void>((r) => (resolver = r))
this.eventEmitter.emit('block', [block, resolver])
return await promise
}
for (let fromGroup = 0; fromGroup < TOTAL_NUMBER_OF_GROUPS; fromGroup++) {
for (let toGroup = 0; toGroup < TOTAL_NUMBER_OF_GROUPS; toGroup++) {
Expand Down

0 comments on commit 232319d

Please sign in to comment.