Skip to content

Commit d56ff6f

Browse files
committed
add logs
1 parent d7c1e6c commit d56ff6f

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

local-tests/setup/shiva-client.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,36 @@ export class TestnetClient {
125125

126126
/**
127127
* Polls a given testnet for the ACTIVE state
128-
* polls on a 500 milisecond interval
128+
* polls on a 3000 millisecond interval
129129
*/
130130
public async pollTestnetForActive(): Promise<string> {
131131
let state = 'Busy';
132-
while (state != 'Active' && state != `UNKNOWN`) {
132+
let pollCount = 0;
133+
const startTime = Date.now(); // Capture start time
134+
135+
while (state !== 'Active' && state !== 'UNKNOWN') {
136+
pollCount++;
137+
133138
const res = await fetch(
134139
this._processEnvs.TESTNET_MANAGER_URL + '/test/poll/testnet/' + this._id
135140
);
136141
const stateRes: TestNetResponse<TestNetState> =
137142
await _processTestnetResponse<TestNetState>(res);
138143
state = stateRes.body;
139-
console.log('found state to be', state);
140144

141-
await new Promise<void>((res, _) => {
142-
setTimeout(() => {
143-
res();
144-
}, 500);
145-
});
145+
console.log(`Poll attempt #${pollCount}: found state to be`, state);
146+
147+
if (state !== 'Active' && state !== 'UNKNOWN') {
148+
await new Promise<void>((resolve) => setTimeout(resolve, 3000));
149+
}
146150
}
147151

152+
const endTime = Date.now(); // Capture end time
153+
const elapsedTime = (endTime - startTime) / 1000; // Convert to seconds
154+
155+
console.log(
156+
`✅ Polling completed after ${pollCount} attempts. Time taken: ${elapsedTime} seconds.`
157+
);
148158
return state;
149159
}
150160

packages/core/src/lib/lit-core.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,16 +554,25 @@ export class LitCore {
554554
}
555555

556556
if (this.config.contractContext) {
557+
console.log(
558+
'❓ this.config.contractContext:',
559+
this.config.contractContext
560+
);
557561
const logAddresses = Object.entries(this.config.contractContext).reduce(
558562
(output, [key, val]) => {
563+
564+
console.log('❓ key:', key);
565+
console.log('❓ val:', val);
566+
559567
// @ts-expect-error since the object hash returned by `getContractAddresses` is `any`, we have no types here
560568
output[key] = val.address;
561569
return output;
562570
},
563571
{}
564572
);
573+
console.log('❓ logAddresses:', logAddresses);
565574
if (this.config.litNetwork === LIT_NETWORK.Custom) {
566-
log('using custom contracts: ', logAddresses);
575+
log('using custom contracts: ', logAddresses);
567576
}
568577
}
569578

0 commit comments

Comments
 (0)