You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You have to implement a setup and teardown function after declaring your common wallet object:
// test-common-wallet is a simple to use wallet for intended for use in testsvartestCommonWallet=require('test-common-wallet');// our wallet benefits from being able to interface with the blockchainvarcommonBlockchain=require('blockcypher-unofficial')({network: "testnet",inBrowser: true});// we seed our wallet with the same text to generate the same bitcoin wallet addressvarcommonWallet=testCommonWallet({network: "testnet",commonBlockchain: commonBlockchain,seed: "someTextSeed"});// and then we check to see if our wallet passes all of the tests and adheres to the protocolvarcommon={setup: function(t,cb){cb(null,commonWallet);},teardown: function(t,commonWallet,cb){cb();}}
To run the tests simply pass your test module (tap or tape or any other compatible modules are supported), the seed you used to generate your commonWallet Object, and your common methods in:
A valid common wallet interface should implement the following functions.
Functions
//callback should be of the form (err, response)cw.signMessage("hey there, this is a message",callback);//this callback should be of the form (err, signedTxHex, txid)cw.signTransaction((someunsignedtransactionhextosign),callback);//will create, sign, and (optionally) propagate a transaction. callback should be of (err, response)cw.createTransaction({value: (theamountofbtctobetransactedinsatoshi),destinationAddress: (theaddressyourCommonWalletobjectwillbesendingbtcto),propagate: (trueorfalseifyouwanttopropagatethetx.Willdefaulttofalse)},callback);//will login to a compatible back-end server using wallet address as an identifiercw.login(host,callback);//will send authenticated requests to compatible back-end servercq.request(options,callback);
Other Common Wallet Data
In addition to the three functions listed above, a common wallet object will also have these two fields:
address: (the public address of the wallet)
network: (the network the wallet is operating on)