-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Alexandre ABRIOUX <alexandre-abrioux@users.noreply.github.com>
- Loading branch information
1 parent
a4910a1
commit 19db1fc
Showing
7 changed files
with
79 additions
and
23 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"header": { | ||
"channelIds": { | ||
"channel1": [0] | ||
}, | ||
"topics": { | ||
"channel1": ["topic1", "topic3"] | ||
}, | ||
"version": "0.1.0" | ||
}, | ||
"transactions": [ | ||
{ | ||
"data": "subsequent transaction for channel1, with different topics" | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,54 @@ | ||
import { afterEach, assert, clearStore, describe, test } from "matchstick-as"; | ||
import { processIpfs } from "./utils"; | ||
|
||
const hash = "testIpfsHash"; | ||
const entityId = hash + "-0"; | ||
const entityType = "Transaction"; | ||
describe("Transaction Data", () => { | ||
afterEach(() => { | ||
clearStore(); | ||
}); | ||
|
||
test("should process clear transactions", () => { | ||
processIpfs("transaction-clear.json"); | ||
assert.entityCount("Transaction", 1); | ||
assert.fieldEquals("Transaction", "testIpfsHash-0", "hash", "testIpfsHash"); | ||
processIpfs("transaction-clear.json", hash); | ||
assert.entityCount(entityType, 1); | ||
assert.fieldEquals(entityType, entityId, "hash", hash); | ||
assert.fieldEquals(entityType, entityId, "channelId", "channel1"); | ||
assert.fieldEquals(entityType, entityId, "topics", "[topic1, topic2]"); | ||
assert.fieldEquals( | ||
"Transaction", | ||
"testIpfsHash-0", | ||
entityType, | ||
entityId, | ||
"dataHash", | ||
"0x09c043a7cb846a048c2e665b832add72046fd9913e05f0c20e7f4f360ce62a8d", | ||
); | ||
|
||
processIpfs("transaction-clear-2.json", "secondTx"); | ||
assert.entityCount(entityType, 2); | ||
assert.fieldEquals(entityType, "secondTx-0", "channelId", "channel1"); | ||
assert.fieldEquals(entityType, "secondTx-0", "topics", "[topic1, topic3]"); | ||
assert.entityCount("Channel", 1); | ||
assert.fieldEquals( | ||
"Channel", | ||
"channel1", | ||
"topics", | ||
"[topic1, topic2, topic3]", | ||
); | ||
}); | ||
|
||
test("should process encrypted transactions", () => { | ||
processIpfs("transaction-encrypted.json"); | ||
assert.entityCount("Transaction", 1); | ||
assert.fieldEquals("Transaction", "testIpfsHash-0", "hash", "testIpfsHash"); | ||
processIpfs("transaction-encrypted.json", hash); | ||
assert.entityCount(entityType, 1); | ||
assert.fieldEquals(entityType, entityId, "hash", hash); | ||
assert.fieldEquals( | ||
"Transaction", | ||
"testIpfsHash-0", | ||
entityType, | ||
entityId, | ||
"dataHash", | ||
"0x3e4bc69070baf9ed30ef58b87b454fd19841f18dd83f7dbe8b311bb32befc483", | ||
); | ||
}); | ||
|
||
test("should ignore wrong transaction data", () => { | ||
processIpfs("transaction-data-invalid-object.json"); | ||
assert.entityCount("Transaction", 0); | ||
processIpfs("transaction-data-invalid-object.json", hash); | ||
assert.entityCount(entityType, 0); | ||
}); | ||
}); |
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