Skip to content
This repository has been archived by the owner on Apr 21, 2020. It is now read-only.

Commit

Permalink
Add test for extractTransactionData()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mykola committed Mar 11, 2018
1 parent 48e8eea commit 82738e7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/TransactionParser.test.ts
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);
})
})
})

0 comments on commit 82738e7

Please sign in to comment.