-
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.
Sketch tests on mainnet (outcome parsing).
- Loading branch information
1 parent
5b74913
commit 4e58c12
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/transactionsOutcomeParsers/smartContractTransactionsOutcomeParser.main.net.spec.ts
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,53 @@ | ||
import { assert } from "chai"; | ||
Check failure on line 1 in src/transactionsOutcomeParsers/smartContractTransactionsOutcomeParser.main.net.spec.ts GitHub Actions / build (16.x)
|
||
import { promises } from "fs"; | ||
import { createMainnetProvider } from "../testutils/networkProviders"; | ||
import { SmartContractTransactionsOutcomeParser } from "./smartContractTransactionsOutcomeParser"; | ||
|
||
describe("test smart contract transactions outcome parser on mainnet", () => { | ||
const networkProvider = createMainnetProvider(); | ||
const parser = new SmartContractTransactionsOutcomeParser(); | ||
|
||
it("should parse (1)", async function () { | ||
this.timeout(3600000); | ||
await testRecords("src/testdata/transactions_01.mainnet.json"); | ||
}); | ||
|
||
it("should parse (2)", async function () { | ||
this.timeout(3600000); | ||
await testRecords("src/testdata/transactions_02.mainnet.json"); | ||
}); | ||
|
||
it("should parse (3)", async function () { | ||
this.timeout(3600000); | ||
await testRecords("src/testdata/transactions_02.mainnet.json"); | ||
}); | ||
|
||
async function testRecords(path: string) { | ||
const content: string = await promises.readFile(path, { encoding: "utf8" }); | ||
const records = JSON.parse(content); | ||
|
||
for (let i = 0; i < records.length; i++) { | ||
const { hash, kind } = records[i]; | ||
const transactionOnNetwork = await networkProvider.getTransaction(hash); | ||
const outcome = parser.parseExecute({ transactionOnNetwork }); | ||
|
||
console.log(i, hash, kind); | ||
console.log(hash, transactionOnNetwork.function, outcome.returnCode, outcome.returnMessage, outcome.values); | ||
|
||
if (kind == "simple_move_balance") { | ||
assert.equal(outcome.returnCode, ""); | ||
assert.equal(outcome.returnMessage, ""); | ||
assert.lengthOf(outcome.values, 0); | ||
} else if (kind == "relayed_error" || kind == "transfer_execute_error" || kind == "execute_error") { | ||
assert.isTrue(outcome.returnCode.length > 0); | ||
assert.isTrue(outcome.returnMessage.length > 0); | ||
assert.lengthOf(outcome.values, 0); | ||
} else if (kind == "relayed_success" || kind == "transfer_execute_success" || kind == "execute_success") { | ||
assert.equal(outcome.returnCode, "ok"); | ||
assert.equal(outcome.returnMessage, "ok"); | ||
} else { | ||
assert.fail("unknown kind"); | ||
} | ||
} | ||
} | ||
}); |