-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stéphane Prohaszka <stephane.prohaszka@ledger.fr>
- Loading branch information
1 parent
66e571a
commit 7e086fc
Showing
2 changed files
with
2,163 additions
and
11,985 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
libs/coin-modules/coin-tezos/src/bridge/prepareTransaction.test.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,72 @@ | ||
import BigNumber from "bignumber.js"; | ||
import { createFixtureAccount, createFixtureTransaction } from "../types/model.fixture"; | ||
import { Transaction } from "../types"; | ||
import prepareTransaction from "./prepareTransaction"; | ||
|
||
describe("prepareTransaction", () => { | ||
it("returns same transaction when account balance is 0", async () => { | ||
// Given | ||
const account = createFixtureAccount({ balance: BigNumber("0") }); | ||
const transaction = createFixtureTransaction(); | ||
|
||
// When | ||
const result = await prepareTransaction(account, transaction); | ||
|
||
// Then | ||
expect(result).toBe(transaction); | ||
}); | ||
|
||
it("returns a transaction with an error when input tx has 0 amount", async () => { | ||
// Given | ||
const account = createFixtureAccount({ balance: BigNumber("1200") }); | ||
const transaction = createFixtureTransaction({ amount: BigNumber("0") }); | ||
|
||
// When | ||
const result = await prepareTransaction(account, transaction); | ||
|
||
// Then | ||
const expectedResult: Transaction = { | ||
amount: BigNumber("0"), | ||
recipient: "tz1VJitLYB31fEC82efFkLRU4AQUH9QgH3q6", | ||
family: "tezos", | ||
mode: "send", | ||
estimatedFees: undefined, | ||
fees: undefined, | ||
gasLimit: undefined, | ||
networkInfo: undefined, | ||
storageLimit: undefined, | ||
taquitoError: "proto.018-Proxford.contract.empty_transaction", | ||
}; | ||
expect(result).toEqual(expectedResult); | ||
}); | ||
|
||
it.skip("returns new transaction", async () => { | ||
// Given | ||
const account = createFixtureAccount({ | ||
freshAddress: "tz1RoqRN77gGpeV96vEXzt62Sns2LViZiUCa", | ||
xpub: "6564706b7647704d6d387246517838655a376a61714b346a735771506879326a366e32394e756d485a315a3774597139664758583947", | ||
balance: BigNumber("1200"), | ||
}); | ||
const transaction = createFixtureTransaction({ amount: BigNumber("12") }); | ||
|
||
// When | ||
const result = await prepareTransaction(account, transaction); | ||
|
||
// Then | ||
const expectedResult: Transaction = { | ||
amount: BigNumber("0"), | ||
recipient: "tz1VJitLYB31fEC82efFkLRU4AQUH9QgH3q6", | ||
family: "tezos", | ||
mode: "send", | ||
estimatedFees: undefined, | ||
fees: undefined, | ||
gasLimit: undefined, | ||
networkInfo: undefined, | ||
storageLimit: undefined, | ||
taquitoError: undefined, | ||
}; | ||
expect(result).toEqual(expectedResult); | ||
expect(result).not.toBe(transaction); | ||
expect(result).toBe(expectedResult); | ||
}); | ||
}); |
Oops, something went wrong.