-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Find by first topic. Additional tests.
- Loading branch information
1 parent
68ea74e
commit 726542f
Showing
4 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { assert } from "chai"; | ||
import { | ||
SmartContractResult, | ||
TransactionEvent, | ||
TransactionLogs, | ||
TransactionOutcome, | ||
findEventsByFirstTopic, | ||
findEventsByIdentifier, | ||
} from "./resources"; | ||
|
||
describe("test resources", () => { | ||
it("finds events by identifier, by first topic", async function () { | ||
const outcome = new TransactionOutcome({ | ||
logs: new TransactionLogs({ | ||
events: [ | ||
new TransactionEvent({ | ||
identifier: "foo", | ||
topics: [Buffer.from("a")], | ||
}), | ||
], | ||
}), | ||
smartContractResults: [ | ||
new SmartContractResult({ | ||
logs: new TransactionLogs({ | ||
events: [ | ||
new TransactionEvent({ | ||
identifier: "foo", | ||
topics: [Buffer.from("b")], | ||
}), | ||
new TransactionEvent({ | ||
identifier: "bar", | ||
topics: [Buffer.from("c")], | ||
}), | ||
], | ||
}), | ||
}), | ||
], | ||
}); | ||
|
||
const foundByIdentifierFoo = findEventsByIdentifier(outcome, "foo"); | ||
const foundByIdentifierBar = findEventsByIdentifier(outcome, "bar"); | ||
const foundByTopic = findEventsByFirstTopic(outcome, "b"); | ||
|
||
assert.deepEqual(foundByIdentifierFoo, [ | ||
new TransactionEvent({ | ||
identifier: "foo", | ||
topics: [Buffer.from("a")], | ||
}), | ||
new TransactionEvent({ | ||
identifier: "foo", | ||
topics: [Buffer.from("b")], | ||
}), | ||
]); | ||
|
||
assert.deepEqual(foundByIdentifierBar, [ | ||
new TransactionEvent({ | ||
identifier: "bar", | ||
topics: [Buffer.from("c")], | ||
}), | ||
]); | ||
|
||
assert.deepEqual(foundByTopic, [ | ||
new TransactionEvent({ | ||
identifier: "foo", | ||
topics: [Buffer.from("b")], | ||
}), | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters