Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 670377c

Browse files
committed
Improve logging
bridge timeout probably too low for real world?
1 parent 13b20b3 commit 670377c

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/dataunion/Contracts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { BigNumber } from '@ethersproject/bignumber'
1212
import StreamrEthereum from '../Ethereum'
1313
import { StreamrClient } from '../StreamrClient'
1414

15-
const log = debug('StreamrClient::DataUnion')
15+
const log = debug('StreamrClient::Contracts')
1616

1717
function validateAddress(name: string, address: EthereumAddress) {
1818
if (!isAddress(address)) {
@@ -149,7 +149,7 @@ export class Contracts {
149149

150150
const [vArray, rArray, sArray]: Todo = [[], [], []]
151151
signatures.forEach((signature: string, i) => {
152-
log(` Signature ${i}: ${signature} (len=${signature.length}=${signature.length / 2 - 1} bytes)`)
152+
log(` Signature ${i}: ${signature} (len=${signature.length} = ${signature.length / 2 - 1} bytes)`)
153153
rArray.push(signature.substr(2, 64))
154154
sArray.push(signature.substr(66, 64))
155155
vArray.push(signature.substr(130, 2))

src/dataunion/DataUnion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ export class DataUnion {
624624
if (!payForTransport) {
625625
// expect someone else to do the transport for us (corresponds to dataUnion.freeWithdraw=true)
626626
if (waitUntilTransportIsComplete) {
627-
log(`Waiting for balance ${balanceBefore.toString()} to change`)
627+
log(`Waiting for balance ${balanceBefore.toString()} to change (poll every ${pollingIntervalMs}ms, timeout after ${retryTimeoutMs}ms)`)
628628
await until(async () => !(await getBalanceFunc()).eq(balanceBefore), retryTimeoutMs, pollingIntervalMs)
629629
.catch((e) => { throw e.message.startsWith('Timeout') ? new Error(`Timeout: Bridge did not transport withdraw message as expected. Fix: DataUnion.transportMessage("${messageHash}")`) : e })
630630
return null

test/integration/dataunion/withdraw.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,26 @@ describe('DataUnion withdraw', () => {
189189
// emulate the bridge-sponsored withdrawals
190190
beforeAll(() => {
191191
if (!payForTransport && waitUntilTransportIsComplete) {
192+
log('Starting the simulated bridge-sponsored signature transport process')
192193
// event UserRequestForSignature(bytes32 indexed messageId, bytes encodedData)
193194
const signatureRequestEventSignature = '0x520d2afde79cbd5db58755ac9480f81bc658e5c517fcae7365a3d832590b0183'
194195
const sidechainAmbAddress = '0xaFA0dc5Ad21796C9106a36D68f69aAD69994BB64'
195196
providerSidechain.on({
196197
address: sidechainAmbAddress,
197198
topics: [signatureRequestEventSignature]
198199
}, async (event) => {
199-
const message = defaultAbiCoder.decode(['bytes'], event.data)[0] // messageId is indexed so it's in topics, only encodedData is in data
200+
log(`Observed signature request for message id=${event.topic[1]}`) // messageId is indexed so it's in topics...
201+
const message = defaultAbiCoder.decode(['bytes'], event.data)[0] // ...only encodedData is in data
200202
const hash = keccak256(message)
201203
const adminClient = new StreamrClient(config.clientOptions)
202204
await adminClient.getDataUnion('0x0000000000000000000000000000000000000000').transportMessage(hash)
205+
log(`Transported message hash=${hash}`)
203206
})
204207
}
205208
})
206209
afterAll(() => {
207210
if (!payForTransport && waitUntilTransportIsComplete) {
211+
log('Stopping the simulated bridge-sponsored signature transport process')
208212
providerSidechain.removeAllListeners()
209213
}
210214
})

0 commit comments

Comments
 (0)