This repository has been archived by the owner on Apr 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for extractTransactionData()
- Loading branch information
Mykola
committed
Mar 11, 2018
1 parent
48e8eea
commit 82738e7
Showing
1 changed file
with
35 additions
and
0 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,35 @@ | ||
|
||
import { TransactionParser } from "../src/common/TransactionParser"; | ||
import * as mocha from "mocha"; | ||
import { block, contractCreateTrx, ethTransferTrx } from "./SeedData"; | ||
import { should, expect } from "chai" | ||
|
||
|
||
describe("Test TransactionParser", () => { | ||
describe("Test extractTransactionData()", () => { | ||
const extractTransactionData = new TransactionParser().extractTransactionData; | ||
it("Should extract transaction data", () => { | ||
const transaction = extractTransactionData(block, ethTransferTrx); | ||
|
||
transaction.should.to.have.property("_id").to.be.a("string"); | ||
transaction.should.to.have.property("blockNumber").to.be.a("number"); | ||
transaction.should.to.have.property("timeStamp").to.be.a("string"); | ||
transaction.should.to.have.property("nonce").to.be.a("number"); | ||
transaction.should.to.have.property("from").to.be.a("string"); | ||
transaction.should.to.have.property("to").to.be.a("string"); | ||
transaction.should.to.have.property("value").to.be.a("string"); | ||
transaction.should.to.have.property("gas").to.be.a("string"); | ||
transaction.should.to.have.property("gasPrice").to.be.a("string"); | ||
transaction.should.to.have.property("gasUsed").to.be.a("string"); | ||
transaction.should.to.have.property("input").to.be.a("string"); | ||
transaction.should.to.have.property("addresses").to.be.a("array"); | ||
}) | ||
|
||
it("Should extract contract creation transaction correctly", () => { | ||
const transaction = extractTransactionData(block, contractCreateTrx); | ||
|
||
expect(transaction.to).to.equal(""); | ||
expect(transaction.addresses).to.have.lengthOf(1); | ||
}) | ||
}) | ||
}) |