This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from blockchain/duplicate-txs
Check for duplicate transactions
- Loading branch information
Showing
6 changed files
with
124 additions
and
5 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
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,44 @@ | ||
proxyquire = require('proxyquireify')(require) | ||
MyWallet = { | ||
wallet: { | ||
getHistory: () -> | ||
syncWallet: () -> | ||
} | ||
} | ||
|
||
stubs = { | ||
'./wallet': MyWallet, | ||
} | ||
|
||
WalletStore = proxyquire('../src/wallet-store', stubs) | ||
|
||
describe "WalletStore", -> | ||
|
||
beforeEach -> | ||
spyOn(MyWallet, "syncWallet") | ||
spyOn(MyWallet.wallet, "getHistory") | ||
|
||
describe "instance", -> | ||
beforeEach -> | ||
|
||
describe "getTransactions()", -> | ||
it "should return nothing initially", -> | ||
expect(WalletStore.getTransactions()).toEqual([]) | ||
|
||
describe "pushTransaction()", -> | ||
|
||
it "add a transaction", -> | ||
tx = {hash: "1234"} | ||
WalletStore.pushTransaction(tx) | ||
expect(WalletStore.getTransactions()).toEqual([tx]) | ||
|
||
describe "getTransaction()", -> | ||
it "should return a transaction with the right hash", -> | ||
tx1 = {hash: "1234"} | ||
tx2 = {hash: "5678"} | ||
|
||
WalletStore.pushTransaction(tx1) | ||
WalletStore.pushTransaction(tx2) | ||
|
||
expect(WalletStore.getTransaction("1234")).toEqual(tx1) | ||
expect(WalletStore.getTransaction("5678")).toEqual(tx2) |