Skip to content

Commit

Permalink
[integritee-worker] make the test more accurate 2
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb committed Nov 10, 2024
1 parent e074603 commit 28421c8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/worker-api/src/integriteeWorker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,15 @@ describe('worker', () => {
describe('should return note of the executed trusted call', () => {
it('should return balance transfer with note as note', async () => {
const shard = network.shard;
const testNote = "My test note";
const result = await worker.trustedBalanceTransfer(
alice,
shard,
network.mrenclave,
alice.address,
charlie.address,
1100000000000,
"My test note"
testNote
);
console.log('balance transfer result', JSON.stringify(result));
expect(result).toBeDefined();
Expand All @@ -159,10 +160,15 @@ describe('worker', () => {
// equal to 1 for a clean start, but it is more for subsequent runs.
expect(notes.length).toBeGreaterThanOrEqual(1);

// Check that the most recent node is the one we just send before
expect(notes.pop()!.timestamp.toNumber() < Date.now());
// Check that the most recent note is the one we just sent before
const note = notes.pop()!;
expect(note.note.isSuccessfulTrustedCall);
const call = worker.createType('IntegriteeTrustedCall', note.note.asSuccessfulTrustedCall);
expect(call.isBalanceTransferWithNote);
expect(call.asBalanceTransferWithNote[3].toString()).toEqual(testNote)
expect(note.timestamp.toNumber() < Date.now());
const oneMinuteMs = 60 * 1000;
expect(notes.pop()!.timestamp.toNumber() > Date.now() - oneMinuteMs);
expect(note.timestamp.toNumber() > Date.now() - oneMinuteMs);
});
});

Expand Down

0 comments on commit 28421c8

Please sign in to comment.