Forked from rest.bitcoin.com commit 50f5c6ed1bd8d10b72bb8851972446240604eee6 5-3-2019

This commit is contained in:
Chris Troutner
2019-05-21 07:42:39 -07:00
commit 5c81669478
134 changed files with 93274 additions and 0 deletions
+160
View File
@@ -0,0 +1,160 @@
/*
This library contains mocking data for running unit tests on the address route.
*/
"use strict"
const mockAddressDetails = {
addrStr: "1Fg4r9iDrEkCcDmHTy2T79EusNfhyQpu7W",
balance: 0.00126419,
balanceSat: 126419,
totalReceived: 0.02175868,
totalReceivedSat: 2175868,
totalSent: 0.02049449,
totalSentSat: 2049449,
unconfirmedBalance: 0,
unconfirmedBalanceSat: 0,
unconfirmedTxApperances: 0,
txApperances: 3,
transactions: [
"2dc053f55a666a3d2a08b1c680b704d62a55506d14ad884add87edcc56b9277d",
"544c15ce35c0f2e808d28f29d6587f1ec9276233e29856b7f2938cf0daef0026",
"81039b1d7b855b133f359f9dc65f776bd105650153a941675fedc504228ddbd3"
],
legacyAddress: "1Fg4r9iDrEkCcDmHTy2T79EusNfhyQpu7W",
cashAddress: "bitcoincash:qzs02v05l7qs5s24srqju498qu55dwuj0cx5ehjm2c"
}
const mockUtxoDetails = [
{
txid: "15f6a584080b04911121fbaca7bfcf3dd64ef2bfa5a01daf31e05a296c3e5e9e",
vout: 286,
amount: 0.00001,
satoshis: 1000,
height: 546083,
confirmations: 3490
},
{
txid: "15f6a584080b04911121fbaca7bfcf3dd64ef2bfa5a01daf31e05a296c3e5e9e",
vout: 287,
amount: 0.00001,
satoshis: 1000,
height: 546083,
confirmations: 3490
},
{
txid: "15f6a584080b04911121fbaca7bfcf3dd64ef2bfa5a01daf31e05a296c3e5e9e",
vout: 288,
amount: 0.00001,
satoshis: 1000,
height: 546083,
confirmations: 3490
}
]
const mockUnconfirmed = [
{
address: "1EzdL6TBbkNhnB2fYiBaKmcs5fxaoqwdAp",
txid: "000c00a90fb5031da6e02f7625df2f8b35a4c16e6feb9fc72293e67e5ff75786",
vout: 0,
scriptPubKey: "76a914997fabcd94a1e2aaa13a7664362e5e7b96c169a988ac",
amount: 0.00999626,
satoshis: 999626,
confirmations: 0,
ts: 1537989425
}
]
const mockTransactions = {
pagesTotal: 1,
txs: [
{
txid: "000c00a90fb5031da6e02f7625df2f8b35a4c16e6feb9fc72293e67e5ff75786",
version: 2,
locktime: 549565,
vin: [
{
txid:
"45c891c6d44619fc85716ba1b593aa83ebc1e500fe611b1ab98531ea203a0f21",
vout: 209,
sequence: 4294967294,
n: 0,
scriptSig: {
hex:
"47304402205b136f348bedae61a87c0500979d47ab02c76f0e4aba866b94c4931fccb5d7dc0220757a141660475b0cd4cb8b1f54b1ace95105f5bea775e817b115fb589fe4477541210246daec651c506f353daa7468714399c773df42ac4d663022d0e446a3331ac64a",
asm:
"304402205b136f348bedae61a87c0500979d47ab02c76f0e4aba866b94c4931fccb5d7dc0220757a141660475b0cd4cb8b1f54b1ace95105f5bea775e817b115fb589fe44775[ALL|FORKID] 0246daec651c506f353daa7468714399c773df42ac4d663022d0e446a3331ac64a"
},
addr: "14TdovsQUL69xL5g3zSzhLpmDb93d9rU9m",
valueSat: 1979534,
value: 0.01979534,
doubleSpentTxID: null
},
{
txid:
"6e5fa79547112a912adf6082c975dc80e282045193512ea369adb6bac7420674",
vout: 147,
sequence: 4294967294,
n: 1,
scriptSig: {
hex:
"473044022056674ac83a37d54ffec2c6d33cfc2ae2256f821b8bd818e1b6783356b49f3d28022046d3dd147c8fc51f2da5d16996a3cea1d7314e327aa1ae1017418737ed20136a4121038f23af565f68d8455e07e5c33c5cfc5114de2f478f035db23eb02f8ff5fe7f6e",
asm:
"3044022056674ac83a37d54ffec2c6d33cfc2ae2256f821b8bd818e1b6783356b49f3d28022046d3dd147c8fc51f2da5d16996a3cea1d7314e327aa1ae1017418737ed20136a[ALL|FORKID] 038f23af565f68d8455e07e5c33c5cfc5114de2f478f035db23eb02f8ff5fe7f6e"
},
addr: "1CEtC2fjELvmAzTd6MWuHb1gvuSq8x3Xpb",
valueSat: 10466,
value: 0.00010466,
doubleSpentTxID: null
}
],
vout: [
{
value: "0.00999626",
n: 0,
scriptPubKey: {
hex: "76a914997fabcd94a1e2aaa13a7664362e5e7b96c169a988ac",
asm:
"OP_DUP OP_HASH160 997fabcd94a1e2aaa13a7664362e5e7b96c169a9 OP_EQUALVERIFY OP_CHECKSIG",
addresses: ["1EzdL6TBbkNhnB2fYiBaKmcs5fxaoqwdAp"],
type: "pubkeyhash"
},
spentTxId: null,
spentIndex: null,
spentHeight: null
},
{
value: "0.00990000",
n: 1,
scriptPubKey: {
hex: "76a914e3335e4d6babe61ea58311293c1c6bfe802801cb88ac",
asm:
"OP_DUP OP_HASH160 e3335e4d6babe61ea58311293c1c6bfe802801cb OP_EQUALVERIFY OP_CHECKSIG",
addresses: ["1MiKvgaQTFCTEZbSDMZgw9ahaB52Cr4ofb"],
type: "pubkeyhash"
},
spentTxId: null,
spentIndex: null,
spentHeight: null
}
],
blockhash:
"00000000000000000158b1a2883688873ec5ea076e3b0f576bcdfe1fd277880f",
blockheight: 549601,
confirmations: 5,
time: 1537990026,
blocktime: 1537990026,
valueOut: 0.01989626,
size: 372,
valueIn: 0.0199,
fees: 0.00000374
}
]
}
module.exports = {
mockAddressDetails,
mockUtxoDetails,
mockUnconfirmed,
mockTransactions
}
+42
View File
@@ -0,0 +1,42 @@
/*
This library contains mocking data for running unit tests on the address route.
*/
"use strict"
const mockBlockDetails = {
hash: "00000000000000645dec6503d3f5eafb0d2537a7a28f181d721dec7c44154c79",
size: 1319,
height: 1267544,
version: 536870912,
merkleroot:
"c2cd01ec2cf149acc7631385f89ae103d1a2ad212ab810c862d9680a811618ce",
tx: [
"52bfa89d449fef8070ec33e7a61f5ec8b5417ff62b050cd6a144ebce9557e0fa",
"8988e8742d2523f667c2d1374861919e3a82903e059fec75c10795da2303b93b",
"41def004f22b196d675566a6983ecf97611e72c48375b8ba779983d5ccd369d7",
"8ca8efb06abb94395f8331f87e101504dcf66aee828f2111922f056971fa7502",
"9ab409cbb203be7cf22bd6598d787fcdd5b417d885b72207ecc7253470770649"
],
time: 1542048973,
nonce: 3936284753,
bits: "1a03c148",
difficulty: 4467892.99177529,
chainwork: "00000000000000000000000000000000000000000000003ee27b503a064045bd",
confirmations: 3,
previousblockhash:
"00000000000001891202cbe18729a02a8763cf04da0ca7aded6e6c7d9b500785",
nextblockhash:
"000000000000039b93b3f3403a0eb21150904b15229d998cf3788fd8bf192cc2",
reward: 0.78125,
isMainChain: true,
poolInfo: {}
}
const mockBlockHash =
"00000000000000645dec6503d3f5eafb0d2537a7a28f181d721dec7c44154c79"
module.exports = {
mockBlockDetails,
mockBlockHash
}
+271
View File
@@ -0,0 +1,271 @@
/*
This library contains mocking data for running unit tests on the address route.
*/
"use strict"
const mockBlockHash =
"00000000000000645dec6503d3f5eafb0d2537a7a28f181d721dec7c44154c79"
const mockBlockchainInfo = {
chain: "test",
blocks: 1267694,
headers: 1267694,
bestblockhash:
"000000000000013eaf80d1e157e32804c36a58ad0bb26ca59833880c80298780",
difficulty: 4105763.969035785,
mediantime: 1542131305,
verificationprogress: 0.9999968911571566,
chainwork: "00000000000000000000000000000000000000000000003f0443b0b5f02ce255",
pruned: false,
softforks: [
{ id: "bip34", version: 2, reject: { status: true } },
{ id: "bip66", version: 3, reject: { status: true } },
{ id: "bip65", version: 4, reject: { status: true } }
],
bip9_softforks: {
csv: {
status: "active",
startTime: 1456790400,
timeout: 1493596800,
since: 770112
}
}
}
const mockChainTips = [
{
height: 1267696,
hash: "000000000000035bfc43a642ebbff8cfc1e88b1d564de8b0a6c7e2797eeafb21",
branchlen: 0,
status: "active"
},
{
height: 1267581,
hash: "000000000001bd12e4124207682563135b21353ca3087bc6b0c409f7f9e1da91",
branchlen: 1,
status: "valid-fork"
},
{
height: 1267375,
hash: "00000000702036979df70236bcc45dfc72d43d5d0e6834007afa1fa627e49587",
branchlen: 1036,
status: "headers-only"
},
{
height: 1266979,
hash: "00000000e851abbde2174ccdc5c2508b909f81f23c4b7abeac864eee1a4891c7",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266973,
hash: "000000007e1324d2900ed70947f89ab8fd4a267e87c9244c333215659a7370d5",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266967,
hash: "000000000f37f12843d4800f50ec4de44dce0432e4d448242d43ff04a7a2948d",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266963,
hash: "00000000ae11ec99e88898cbd72567cb4cb79e7fc13243357bef79632769deb4",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266962,
hash: "000000004f97851259b4460a049e44fa5bd4beadee04a85bf81bd2e90c4f24f9",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266950,
hash: "00000000d12a0e4a827f73ecaadb563df7e99817294939f2be8e943079dc60b2",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266944,
hash: "00000000612d16af273217818e8e7ac5014a19f68ed04e1bc897b1be0a9c744f",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266941,
hash: "0000000000002b91cdb15cacf3368da2c9ffce511d64092193b507dad75f4a27",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266896,
hash: "000000000002745f67a66617b1f9f65c2dfb4c4b8a9ed9b1320b98d3ca46cbe5",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266481,
hash: "0000000000036babee3ba7654cddb29a9fe5e85c9fbeb44bb53d5ffb694b9670",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266452,
hash: "00000000502c3ab1490e0839780a4b441bbe21507c454545941e6adcde73c2ff",
branchlen: 1,
status: "valid-fork"
},
{
height: 1266336,
hash: "000000001c9a0b7cd9eb2210f69d5a9a3f4546ba3707deb40993d729190582d7",
branchlen: 10,
status: "headers-only"
},
{
height: 1266097,
hash: "000000000028ac0fbd18afe6f001f70cb7549bd2b3082d754dde88ee236368a2",
branchlen: 1,
status: "valid-fork"
},
{
height: 1265522,
hash: "00000000000000c6df7a2063030e6ce51399e470cc46e4bf6d67aa3f0feca98d",
branchlen: 1,
status: "valid-fork"
},
{
height: 1265470,
hash: "0000000000168e6442a595a02340fccf8dc2b0e8912c632d39e1f870685f6d7c",
branchlen: 2,
status: "valid-fork"
},
{
height: 1265275,
hash: "000000008bc2b37ae6af1b886b52e7e1c1122c12badc4ae6c13df64f789267cf",
branchlen: 11027,
status: "headers-only"
},
{
height: 1265257,
hash: "00000000005bc3e9973d7273211eab02ae02549c7ebae48764c0bd648d4d7bbe",
branchlen: 114,
status: "valid-fork"
},
{
height: 1265254,
hash: "0000000000e5b909d3541857315e9ee103b042d9ba661f25cc3e8fb25a96c8ce",
branchlen: 111,
status: "valid-fork"
},
{
height: 1265245,
hash: "000000000066eb8832f6f990baceb379536f437216e22475a6c1b9133d250cb8",
branchlen: 102,
status: "valid-fork"
},
{
height: 1264455,
hash: "00000000000001befc1bb17a23208d0b77b2449e37093ce8fbb5e346b19cafcc",
branchlen: 1,
status: "valid-headers"
},
{
height: 1264373,
hash: "00000000000001ed3747e04fb95054cac0358fb4d8009d1999fc3ea34413e84a",
branchlen: 175,
status: "valid-fork"
},
{
height: 1263912,
hash: "00000000000004635aecbcb97edcd6f5396483338838cb40da804eb354c68bde",
branchlen: 1,
status: "valid-fork"
},
{
height: 1262906,
hash: "00000000b31643d92a3e7c38e9755844fc8607e3f1055580a8ff28854e8a8ece",
branchlen: 1,
status: "valid-fork"
},
{
height: 1255749,
hash: "000000001dde5b015a99137f4cba87871370f4b6fcfbcc8b126547e6c33177da",
branchlen: 129,
status: "headers-only"
},
{
height: 1188789,
hash: "00000000af942ce4eb60b3213cbcb7c98a7330f1f8f1adb4b6376f5e822e15b2",
branchlen: 92,
status: "headers-only"
}
]
const mockMempoolInfo = {
size: 87,
bytes: 16816,
usage: 66408,
maxmempool: 300000000,
mempoolminfee: 0
}
const mockRawMempool = [
"db045bc3bd1088fa91f5ebb05c35cb9e2a91a22377f79b465cc6920b9893123c",
"6b3df7febf2b9834f1409155f88b866dd516b36376eae00e2b455df82e290405"
]
const mockBlockHeaderConcise =
"0000ff7f7d217c9b7845ea8b50d620c59a1bf7c276566406e9b7bc7e463e0000000000006d70322c0b697c1c81d2744f87f09f1e9780ba5d30338952e2cdc64e60456f8423bb0a5ceafa091a3e843526"
const mockBlockHeader = {
hash: "00000000000008c3679777df34f1a09565f98b2400a05b7c8da72525fdca3900",
confirmations: 7,
height: 1272859,
version: 2147418112,
versionHex: "7fff0000",
merkleroot:
"846f45604ec6cde2528933305dba80971e9ff0874f74d2811c7c690b2c32706d",
time: 1544207139,
mediantime: 1544202884,
nonce: 641041470,
bits: "1a09faea",
difficulty: 1681035.704111868,
chainwork: "00000000000000000000000000000000000000000000003fc4752e608403be04",
previousblockhash:
"0000000000003e467ebcb7e906645676c2f71b9ac520d6508bea45789b7c217d",
nextblockhash:
"00000000000006899041cdfd6c0b73a97730c362346dde479b77414ad7f25ace"
}
const mockTxOut = {
bestblock: "00000000003a7f19730dd9f172d7466658a5c8833dd03ed8f4ba36e3d857b5e7",
confirmations: 10,
value: 0.0001,
scriptPubKey: {
asm:
"OP_DUP OP_HASH160 0ee020c07f39526ac5505c54fa1ab98490979b83 OP_EQUALVERIFY OP_CHECKSIG",
hex: "76a9140ee020c07f39526ac5505c54fa1ab98490979b8388ac",
reqSigs: 1,
type: "pubkeyhash",
addresses: ["bchtest:qq8wqgxq0uu4y6k92pw9f7s6hxzfp9umsvtg39pzqf"]
},
coinbase: false
}
const mockTxOutProof =
"000000200798039affceb7a381e15dc62443c286efe7cae852393b656807000000000000cf9a7d6c654fd1c4558229a619a550ff749b373fa0f0027eed68b1abf6175d5c07c50f5cffff001d0452403b34000000070d0765da76980d542b5670d27ccda9e717073270f8921ad017deb7ee83fe6c4c22830a48cc8392197f1742a3d81805bd2aa4eb7469f38c74f674429d682cb87efcff1713fd0c388a50f0d11adf05363397ef79d16cdb786d47c941c2cb89f2588f42aced9c05f4203b4440616a9e4266ec47909b9580a643f402b5d4e82cc3cddd73df05a33abf6af3975d973d3033d10c4168a73d58d01f685a96d5a2519cd0de9c77faf3f8725ddf155cbdc8ab8102f173e2d0a0d74767f3bff22f588158d6d5bc71c079c7659cc864819c43877635007650502eb4060fcc9feec3280a41d602ad0a"
module.exports = {
mockBlockHash,
mockBlockchainInfo,
mockChainTips,
mockMempoolInfo,
mockRawMempool,
mockBlockHeaderConcise,
mockBlockHeader,
mockTxOut,
mockTxOutProof
}
+27
View File
@@ -0,0 +1,27 @@
/*
This library contains mocking data for running unit tests on the address route.
*/
"use strict"
const mockGetInfo = {
version: 170200,
protocolversion: 70015,
walletversion: 160300,
balance: 0,
blocks: 1266726,
timeoffset: 0,
connections: 8,
proxy: "",
difficulty: 1,
testnet: true,
keypoololdest: 1536331195,
keypoolsize: 2000,
paytxfee: 0,
relayfee: 0.00001,
errors: "Warning: unknown new rules activated (versionbit 28)"
}
module.exports = {
mockGetInfo
}
+88
View File
@@ -0,0 +1,88 @@
/*
Contains mocks of Express req and res objects.
*/
"use strict"
const sinon = require("sinon")
// Inspect JS Objects.
const util = require("util")
util.inspect.defaultOptions = {
showHidden: true,
colors: true
}
// mock for res.send()
function fakeSend(arg) {
//console.log(`res.send: ${util.inspect(arg)}`);
mockRes.output = arg
return arg
}
// mock for res.json()
function fakeJson(arg) {
//console.log(`res.json: ${util.inspect(arg)}`);
mockRes.output = arg
return arg
}
// mock for res.setStatus(num)
const setStatusCode = arg => {
mockRes.statusCode = arg
}
const mockReq = {
accepts: sinon.stub().returns({}),
acceptsCharsets: sinon.stub().returns({}),
acceptsEncodings: sinon.stub().returns({}),
acceptsLanguages: sinon.stub().returns({}),
body: {},
flash: sinon.stub().returns({}),
get: sinon.stub().returns({}),
is: sinon.stub().returns({}),
params: {},
query: {},
session: {},
locals: {},
headers: {}
}
const mockRes = {
append: sinon.stub().returns({}),
attachement: sinon.stub().returns({}),
clearCookie: sinon.stub().returns({}),
cookie: sinon.stub().returns({}),
download: sinon.stub().returns({}),
end: sinon.stub().returns({}),
format: {},
get: sinon.stub().returns({}),
headersSent: sinon.stub().returns({}),
json: sinon.stub().callsFake(fakeJson),
jsonp: sinon.stub().returns({}),
links: sinon.stub().returns({}),
locals: {},
location: sinon.stub().returns({}),
output: null, // Used for retrieving output data.
redirect: sinon.stub().returns({}),
render: sinon.stub().returns({}),
send: sinon.stub().callsFake(fakeSend),
sendFile: sinon.stub().returns({}),
sendStatus: sinon.stub().returns({}),
set: sinon.stub().returns({}),
status: sinon.stub().callsFake(setStatusCode),
statusCode: null, // Default value before calling stats();
type: sinon.stub().returns({}),
vary: sinon.stub().returns({}),
write: sinon.stub().returns({}),
setHeader: sinon.stub().returns({}),
format: sinon.stub().returns({})
}
const mockNext = sinon.stub().returns()
module.exports = {
mockReq,
mockRes,
mockNext
}
+22
View File
@@ -0,0 +1,22 @@
/*
This library contains mocking data for running unit tests on the address route.
*/
"use strict"
const mockMiningInfo = {
blocks: 1270185,
currentblocksize: 0,
currentblocktx: 0,
difficulty: 1,
blockprioritypercentage: 5,
errors:
"Warning: Unknown block versions being mined! It's possible unknown rules are in effect",
networkhashps: 517410290.9365583,
pooledtx: 5,
chain: "test"
}
module.exports = {
mockMiningInfo
}
+157
View File
@@ -0,0 +1,157 @@
/*
This library contains mocking data for running unit tests.
*/
"use strict"
const mockDecodeRawTransaction = {
txid: "a332237d82a2543af1b0e1ae3c8cea1610c290ebcaf084a7e9894a61de0be988",
hash: "a332237d82a2543af1b0e1ae3c8cea1610c290ebcaf084a7e9894a61de0be988",
size: 226,
version: 2,
locktime: 0,
vin: [
{
txid: "21cced645eab150585ed7ca7c96edebab5793cc0a3b3b286c42fd7d6d798b5b9",
vout: 1,
scriptSig: {
asm:
"3045022100a7b1b08956abb8d6f322aa709d8583c8ea492ba0585f1a6f4f9983520af74a5a0220411aee4a9a54effab617b0508c504c31681b15f9b187179b4874257badd41390[ALL|FORKID] 0360cfc66fdacb650bc4c83b4e351805181ee696b7d5ab4667c57b2786f51c413d",
hex:
"483045022100a7b1b08956abb8d6f322aa709d8583c8ea492ba0585f1a6f4f9983520af74a5a0220411aee4a9a54effab617b0508c504c31681b15f9b187179b4874257badd4139041210360cfc66fdacb650bc4c83b4e351805181ee696b7d5ab4667c57b2786f51c413d"
},
sequence: 4294967295
}
],
vout: [
{
value: 0.0001,
n: 0,
scriptPubKey: {
asm:
"OP_DUP OP_HASH160 eb4b180def88e3f5625b2d8ae2c098ff7d85f664 OP_EQUALVERIFY OP_CHECKSIG",
hex: "76a914eb4b180def88e3f5625b2d8ae2c098ff7d85f66488ac",
reqSigs: 1,
type: "pubkeyhash",
addresses: [Array]
}
},
{
value: 0.09989752,
n: 1,
scriptPubKey: {
asm:
"OP_DUP OP_HASH160 eb4b180def88e3f5625b2d8ae2c098ff7d85f664 OP_EQUALVERIFY OP_CHECKSIG",
hex: "76a914eb4b180def88e3f5625b2d8ae2c098ff7d85f66488ac",
reqSigs: 1,
type: "pubkeyhash",
addresses: [Array]
}
}
]
}
const mockDecodeScript = {
asm:
"0 0 -57 OP_NOP6 OP_LSHIFT OP_UNKNOWN OP_UNKNOWN OP_UNKNOWN c486b2b3a3c03c79b5bade6ec9a77ced850515ab5e64edcc21010000006b483045022100a7b1b08956abb8d6f322aa OP_2OVER OP_NUMEQUALVERIFY OP_OR OP_INVERT OP_UNKNOWN OP_UNKNOWN 2ba0585f1a6f4f9983520af74a5a0220411aee4a9a54effab617b0508c504c31681b15f9b187179b4874257badd4139041210360cfc66fdacb650bc4c83b4e351805181ee696b7d5ab 67c57b2786f51c413dffffffff0210270000000000001976a914eb4b180def88e3f5625b2d8ae2c098ff7d85f66488ac786e9800000000001976a914eb4b180def88e3f5625b [error]",
type: "nonstandard",
p2sh: "bchtest:pzy6dwfy6yf373w0dr05a6flfqksurjhwcl3awhdvm"
}
const mockRawTransactionConcise =
"02000000014e6b52500110b1c30315b85805fb274f0f4afceffc1589f889b27709e59e987d000000006a473044022052762770baa71c1a0b9544ad0f1ea343d32c22aa87c5f8397b6852f464c15b1e02201f4390745cb470e21e0e3c14229f39fef55ea0643a4c997f99d9f3501eae09b7412103c346eee77a77a8d3e073dacc0532ca7a5b9747bc06d88bf091cac9f4bc8bb792ffffffff02d1778f950a0000001976a91436d2f27bbd826a86db1e93618ce3de89ef33169388ac80969800000000001976a914152ea3cd65f18cb8fa9146c84ea1a97af8f051de88ac00000000"
const mockRawTransactionVerbose = {
hex:
"02000000014e6b52500110b1c30315b85805fb274f0f4afceffc1589f889b27709e59e987d000000006a473044022052762770baa71c1a0b9544ad0f1ea343d32c22aa87c5f8397b6852f464c15b1e02201f4390745cb470e21e0e3c14229f39fef55ea0643a4c997f99d9f3501eae09b7412103c346eee77a77a8d3e073dacc0532ca7a5b9747bc06d88bf091cac9f4bc8bb792ffffffff02d1778f950a0000001976a91436d2f27bbd826a86db1e93618ce3de89ef33169388ac80969800000000001976a914152ea3cd65f18cb8fa9146c84ea1a97af8f051de88ac00000000",
txid: "bd320377db7026a3dd5c7ec444596c0ee18fc25c4f34ee944adc03e432ce1971",
hash: "bd320377db7026a3dd5c7ec444596c0ee18fc25c4f34ee944adc03e432ce1971",
size: 225,
version: 2,
locktime: 0,
vin: [
{
txid: "7d989ee50977b289f88915fceffc4a0f4f27fb0558b81503c3b1100150526b4e",
vout: 0,
scriptSig: {
asm:
"3044022052762770baa71c1a0b9544ad0f1ea343d32c22aa87c5f8397b6852f464c15b1e02201f4390745cb470e21e0e3c14229f39fef55ea0643a4c997f99d9f3501eae09b7[ALL|FORKID] 03c346eee77a77a8d3e073dacc0532ca7a5b9747bc06d88bf091cac9f4bc8bb792",
hex:
"473044022052762770baa71c1a0b9544ad0f1ea343d32c22aa87c5f8397b6852f464c15b1e02201f4390745cb470e21e0e3c14229f39fef55ea0643a4c997f99d9f3501eae09b7412103c346eee77a77a8d3e073dacc0532ca7a5b9747bc06d88bf091cac9f4bc8bb792"
},
sequence: 4294967295
}
],
vout: [
{
value: 454.58880465,
n: 0,
scriptPubKey: {
asm:
"OP_DUP OP_HASH160 36d2f27bbd826a86db1e93618ce3de89ef331693 OP_EQUALVERIFY OP_CHECKSIG",
hex: "76a91436d2f27bbd826a86db1e93618ce3de89ef33169388ac",
reqSigs: 1,
type: "pubkeyhash",
addresses: ["bchtest:qqmd9unmhkpx4pkmr6fkrr8rm6y77vckjvqe8aey35"]
}
},
{
value: 0.1,
n: 1,
scriptPubKey: {
asm:
"OP_DUP OP_HASH160 152ea3cd65f18cb8fa9146c84ea1a97af8f051de OP_EQUALVERIFY OP_CHECKSIG",
hex: "76a914152ea3cd65f18cb8fa9146c84ea1a97af8f051de88ac",
reqSigs: 1,
type: "pubkeyhash",
addresses: ["bchtest:qq2jag7dvhccew86j9rvsn4p49a03uz3mcpw3d6aca"]
}
}
],
blockhash: "000000000000026fa244de975ca89ea08008aa566564ce2e8ebb3144361b601b",
confirmations: 125,
time: 1542646373,
blocktime: 1542646373
}
const mockWHDecode = {
txid: "f8a9857fe3b8a288b5fcafb1b0fc196731f433add6d962f77acd7c10b970ff89",
fee: "500",
sendingaddress: "bchtest:qzjtnzcvzxx7s0na88yrg3zl28wwvfp97538sgrrmr",
referenceaddress: "bchtest:qzjtnzcvzxx7s0na88yrg3zl28wwvfp97538sgrrmr",
ismine: false,
version: 0,
type_int: 0,
type: "Simple Send",
propertyid: 368,
precision: "8",
amount: "10.00000000",
valid: true,
blockhash: "0000000046ba0bcef78caaa4492622176bbc563cf249ab52340a0449bc8e26f6",
blocktime: 1542814183,
positioninblock: 57,
block: 1269008,
confirmations: 2
}
const mockWHCreateInput = {
txid: "f7ed9cf23dee85910f6269c9a101a75fcfd2f3c6fc81f17fad824ff7aaf99ab2",
vout: 1,
scriptPubKey: "76a914a4b98b0c118de83e7d39c834445f51dce62425f588ac",
amount: 0.09984138,
satoshis: 9984138,
height: 1269011,
confirmations: 4,
legacyAddress: "mvXwPH74hW2yVTWwDwzsjGoaUAqJvWk7ZJ",
cashAddress: "bchtest:qzjtnzcvzxx7s0na88yrg3zl28wwvfp97538sgrrmr",
value: 0.09984138
}
module.exports = {
mockDecodeRawTransaction,
mockDecodeScript,
mockRawTransactionConcise,
mockRawTransactionVerbose,
mockWHDecode,
mockWHCreateInput
}
+327
View File
@@ -0,0 +1,327 @@
/*
This library contains mocking data for running unit tests.
*/
"use strict"
const mockList = {
t: [
{
tokenDetails: {
tokenIdHex:
"df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb",
documentUri: "",
documentSha256: "",
symbol: "NAKAMOTO",
name: "NAKAMOTO",
decimals: 8
},
tokenStats: {
qty_valid_txns_since_genesis: 241,
qty_valid_token_utxos: 151,
qty_valid_token_addresses: 113,
qty_token_circulating_supply: "20995990",
qty_token_burned: "4010",
qty_token_minted: "21000000",
qty_satoshis_locked_up: 81900
}
}
]
}
const mockSingleToken = {
t: [
{
tokenDetails: {
decimals: 8,
tokenIdHex:
"650dea14c77f4d749608e36e375450c9ac91deb8b1b53e50cb0de2059a52d19a",
timestamp: "2018-08-26 07:06",
transactionType: "GENESIS",
versionType: 1,
documentUri: "",
documentSha256Hex: null,
symbol: "",
name: "TESTYCOIN",
batonVout: null,
containsBaton: false,
genesisOrMintQuantity: "9999",
sendOutputs: null
},
tokenStats: {
block_created: 1253802,
block_last_active_send: 1253802,
block_last_active_mint: null,
qty_valid_txns_since_genesis: 2,
qty_valid_token_utxos: 0,
qty_valid_token_addresses: 0,
qty_token_minted: "9999",
qty_token_burned: "9999",
qty_token_circulating_supply: "0",
qty_satoshis_locked_up: 0,
minting_baton_status: "NEVER_CREATED"
}
}
]
}
const mockSingleTokenError = {
t: []
}
const mockSingleAddress = {
a: [
{
_id: "5c93ed62a19119333d1595bc",
tokenDetails: {
tokenIdHex:
"6b081fcd1f78b187be1464313dac8ff257251b727a42b613552a4040870aeb29"
},
address: "slptest:pz0qcslrqn7hr44hsszwl4lw5r6udkg6zqv7sq3kk7",
satoshis_balance: 546,
token_balance: "4616984"
}
],
t: [
{
tokenDetails: {
decimals: 8,
tokenIdHex:
"6b081fcd1f78b187be1464313dac8ff257251b727a42b613552a4040870aeb29",
timestamp: "2019-02-25 10:05",
transactionType: "GENESIS",
versionType: 1,
documentUri: "https://developer.bitcoin.com",
documentSha256Hex: "",
symbol: "DEV",
name: "DEVCOIN",
batonVout: 2,
containsBaton: true,
genesisOrMintQuantity: "500000000",
sendOutputs: null
},
tokenStats: {
block_created: 571272,
block_last_active_send: 574758,
block_last_active_mint: 571272,
qty_valid_txns_since_genesis: 172,
qty_valid_token_utxos: 170,
qty_valid_token_addresses: 170,
qty_token_minted: "1000000000",
qty_token_burned: "4.99999995",
qty_token_circulating_supply: "999999995.00000005",
qty_satoshis_locked_up: 92820,
minting_baton_status: "ALIVE"
}
}
]
}
const mockTx = {
txid: "57b3082a2bf269b3d6f40fee7fb9c664e8256a88ca5ee2697c05b9457822d446",
version: 2,
locktime: 0,
vin: [
{
txid: "61e71554a3dc18158f30d9e8f5c9b6641a789690b32302899f81cbea9fe3bb49",
vout: 2,
sequence: 4294967295,
n: 0,
scriptSig: {
hex:
"4730440220409e79fec552f01203f41d3d621ae3db89c720af261c8268ce5f0453de009f5d022001e7ffefeba7b0716d32ea55cb6ace267b6ee9cbcc8a017bb9c3b6acf7889418412103c87f0ec048a0771bdb60533d45cac88c6974afeb055a65edd663c2f947335585",
asm:
"30440220409e79fec552f01203f41d3d621ae3db89c720af261c8268ce5f0453de009f5d022001e7ffefeba7b0716d32ea55cb6ace267b6ee9cbcc8a017bb9c3b6acf7889418[ALL|FORKID] 03c87f0ec048a0771bdb60533d45cac88c6974afeb055a65edd663c2f947335585"
},
value: 546,
legacyAddress: "mw22g57T9YA7MZQQu5eBDKj3PKTdt99oDL",
cashAddress: "bchtest:qz4qnxcxwvmacgye8wlakhz0835x0w3vtvaga95c09"
},
{
txid: "61e71554a3dc18158f30d9e8f5c9b6641a789690b32302899f81cbea9fe3bb49",
vout: 1,
sequence: 4294967295,
n: 1,
scriptSig: {
hex:
"483045022100a743bee56c99bd103be48a78fa4c7342100815d9d2448dbe6e1d338c3a13b241022066728b5279fc22eef5cd019582ff34771e29175835fc98aa3168a1548fd78ac8412103c87f0ec048a0771bdb60533d45cac88c6974afeb055a65edd663c2f947335585",
asm:
"3045022100a743bee56c99bd103be48a78fa4c7342100815d9d2448dbe6e1d338c3a13b241022066728b5279fc22eef5cd019582ff34771e29175835fc98aa3168a1548fd78ac8[ALL|FORKID] 03c87f0ec048a0771bdb60533d45cac88c6974afeb055a65edd663c2f947335585"
},
value: 546,
legacyAddress: "mw22g57T9YA7MZQQu5eBDKj3PKTdt99oDL",
cashAddress: "bchtest:qz4qnxcxwvmacgye8wlakhz0835x0w3vtvaga95c09"
},
{
txid: "61e71554a3dc18158f30d9e8f5c9b6641a789690b32302899f81cbea9fe3bb49",
vout: 3,
sequence: 4294967295,
n: 2,
scriptSig: {
hex:
"483045022100821473902eec5f1ce7d43b1ba7f9ec453bfe8b8dfc3de3e0723c883ab109922f02206162960e80618531fab2c16aee260fddd7979bab62471c8686af7de75f8732ec412103c87f0ec048a0771bdb60533d45cac88c6974afeb055a65edd663c2f947335585",
asm:
"3045022100821473902eec5f1ce7d43b1ba7f9ec453bfe8b8dfc3de3e0723c883ab109922f02206162960e80618531fab2c16aee260fddd7979bab62471c8686af7de75f8732ec[ALL|FORKID] 03c87f0ec048a0771bdb60533d45cac88c6974afeb055a65edd663c2f947335585"
},
value: 9997521,
legacyAddress: "mw22g57T9YA7MZQQu5eBDKj3PKTdt99oDL",
cashAddress: "bchtest:qz4qnxcxwvmacgye8wlakhz0835x0w3vtvaga95c09"
}
],
vout: [
{
value: "0.00000000",
n: 0,
scriptPubKey: {
hex:
"6a04534c500001010453454e44207ac7f4bb50b019fe0f5c81e3fc13fc0720e130282ea460768cafb49785eb2796080000000049504f80080000001c71e64280",
asm:
"OP_RETURN 5262419 1 1145980243 7ac7f4bb50b019fe0f5c81e3fc13fc0720e130282ea460768cafb49785eb2796 0000000049504f80 0000001c71e64280"
},
spentTxId: null,
spentIndex: null,
spentHeight: null
},
{
value: "0.00000546",
n: 1,
scriptPubKey: {
hex: "76a914396b8e57ad0cb58d30e2992f22047b3c20377aa688ac",
asm:
"OP_DUP OP_HASH160 396b8e57ad0cb58d30e2992f22047b3c20377aa6 OP_EQUALVERIFY OP_CHECKSIG",
addresses: ["mkkZf7T3fU3vHSzNPy51HBmM46ghN1gnN9"],
type: "pubkeyhash"
},
spentTxId: null,
spentIndex: null,
spentHeight: null
},
{
value: "0.00000546",
n: 2,
scriptPubKey: {
hex: "76a914aa099b067337dc20993bbfdb5c4f3c6867ba2c5b88ac",
asm:
"OP_DUP OP_HASH160 aa099b067337dc20993bbfdb5c4f3c6867ba2c5b OP_EQUALVERIFY OP_CHECKSIG",
addresses: ["mw22g57T9YA7MZQQu5eBDKj3PKTdt99oDL"],
type: "pubkeyhash"
},
spentTxId: null,
spentIndex: null,
spentHeight: null
},
{
value: "0.09996891",
n: 3,
scriptPubKey: {
hex: "76a914aa099b067337dc20993bbfdb5c4f3c6867ba2c5b88ac",
asm:
"OP_DUP OP_HASH160 aa099b067337dc20993bbfdb5c4f3c6867ba2c5b OP_EQUALVERIFY OP_CHECKSIG",
addresses: ["mw22g57T9YA7MZQQu5eBDKj3PKTdt99oDL"],
type: "pubkeyhash"
},
spentTxId: null,
spentIndex: null,
spentHeight: null
}
],
blockhash: "000000000000ce978accc64a6bb567acf0c653c202309a0f8e220149bf0c6968",
blockheight: 1287490,
confirmations: 746,
time: 1550855104,
blocktime: 1550855104,
valueOut: 0.09997983,
size: 628,
valueIn: 0.09998613,
fees: 0.0000063,
tokenInfo: {
versionType: 1,
transactionType: "SEND",
tokenIdHex:
"7ac7f4bb50b019fe0f5c81e3fc13fc0720e130282ea460768cafb49785eb2796",
sendOutputs: ["0", "1230000000", "122170000000"]
},
tokenIsValid: true
}
const mockConvert = {
slpAddress: "slptest:qz35h5mfa8w2pqma2jq06lp7dnv5fxkp2shlcycvd5",
cashAddress: "bchtest:qz35h5mfa8w2pqma2jq06lp7dnv5fxkp2svtllzmlf",
legacyAddress: "mvQPGnzRT6gMWASZBMg7NcT3vmvsSKSQtf"
}
const mockTokenDetails = {
tokenIdHex:
"df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb",
documentUri: "",
symbol: "NAKAMOTO",
name: "NAKAMOTO",
decimals: 8,
timestamp: "",
containsBaton: true,
versionType: 1
}
const mockTokenStats = {
qty_valid_txns_since_genesis: 241,
qty_valid_token_utxos: 151,
qty_valid_token_addresses: 113,
qty_token_circulating_supply: "20995990",
qty_token_burned: "4010",
qty_token_minted: "21000000",
qty_satoshis_locked_up: 81900
}
const mockBalance = {
slpAddress: "simpleledger:qp9d8mn8ypryfvea2mev0ggc3wg6plpn4suuaeuss3",
satoshis_balance: 546,
token_balance: "1000"
}
const mockTransactions = [
{
txid: "a302f045be8efa1cd982833a7f187ff4fac8baac36da0c887eb2787d8b45e2af",
tokenDetails: {
valid: true,
detail: {
decimals: null,
tokenIdHex:
"495322b37d6b2eae81f045eda612b95870a0c2b6069c58f70cf8ef4e6a9fd43a",
timestamp: null,
transactionType: "MINT",
versionType: 1,
documentUri: null,
documentSha256Hex: null,
symbol: null,
name: null,
batonVout: 2,
containsBaton: true,
genesisOrMintQuantity: {
$numberDecimal: "1000"
},
sendOutputs: null
},
invalidReason: null,
schema_version: 30
}
}
]
const mockFoobar = {
c: [],
u: []
}
module.exports = {
mockList,
mockSingleToken,
mockConvert,
mockTokenDetails,
mockTokenStats,
mockTx,
mockBalance,
mockTransactions,
mockSingleTokenError,
mockSingleAddress,
mockFoobar
}
+71
View File
@@ -0,0 +1,71 @@
/*
Mocks used for unit tests that interact with slpjs.
*/
"use strict"
const sinon = require("sinon")
const proxyquire = require("proxyquire")
const BigNumber = require("bignumber.js")
const slpMocks = require("./slp-mocks")
// Mock the BitboxNetwork class.
class BitboxNetwork {
constructor() {}
async getAllSlpBalancesAndUtxos(address) {
return {
satoshis_available_bch: 9996891,
satoshis_in_slp_baton: 546,
satoshis_in_slp_token: 546,
satoshis_in_invalid_token_dag: 0,
satoshis_in_invalid_baton_dag: 0,
slpTokenBalances: {
"7ac7f4bb50b019fe0f5c81e3fc13fc0720e130282ea460768cafb49785eb2796": new BigNumber(
123400000000
)
},
slpTokenUtxos: {
"7ac7f4bb50b019fe0f5c81e3fc13fc0720e130282ea460768cafb49785eb2796": []
},
slpBatonUtxos: {
"7ac7f4bb50b019fe0f5c81e3fc13fc0720e130282ea460768cafb49785eb2796": []
},
nonSlpUtxos: [{}],
invalidTokenUtxos: [],
invalidBatonUtxos: []
}
}
async getTokenInformation(txid) {
BigNumber.set({ DECIMAL_PLACES: 8, ROUNDING_MODE: 4 })
const obj = {
versionType: 1,
transactionType: 0,
symbol: "SLPSDK",
name: "SLP SDK example using BITBOX",
documentUri: "developer.bitcoin.com",
documentSha256: null,
decimals: 8,
batonVout: 2,
containsBaton: true,
genesisOrMintQuantity: new BigNumber(123400000000)
}
return obj
}
async getTransactionDetails(txid) {
return slpMocks.mockTx
}
}
// Mock the slpjs library.
const slpjs = {
BitboxNetwork,
slp: {},
validator: {}
}
module.exports = slpjs
+74
View File
@@ -0,0 +1,74 @@
/*
This library contains mocking data for running unit tests on the address route.
*/
"use strict"
/*
const mockDetails = {
txid: "6f235bd3a689f03c11969cd649ccad592462ca958bc519a30194e7a67b349a40",
version: 2,
locktime: 0,
vin: [Array],
vout: [Array],
blockhash: "00000000e7232ff12462dedf9c11985f5b54202515277c337ccc59812758f28b",
blockheight: 1270188,
confirmations: 2,
time: 1543436253,
blocktime: 1543436253,
valueOut: 450.78867333,
size: 226,
valueIn: 450.78867559,
fees: 0.00000226
}
*/
const mockDetails = {
txid: "6f235bd3a689f03c11969cd649ccad592462ca958bc519a30194e7a67b349a40",
version: 2,
locktime: 0,
vin: [
{
txid: "273d616d1c48f4b075c497f36ffdc79da5c8d6ed75485808b3599aac504f8525",
vout: 0,
sequence: 4294967295,
n: 0,
scriptSig: [{}],
addr: "bchtest:qqmd9unmhkpx4pkmr6fkrr8rm6y77vckjvqe8aey35",
valueSat: 45078867559,
value: 450.78867559,
doubleSpentTxID: null
}
],
vout: [
{
value: "450.68867333",
n: 0,
scriptPubKey: [{}],
spentTxId: null,
spentIndex: null,
spentHeight: null
},
{
value: "0.10000000",
n: 1,
scriptPubKey: [{}],
spentTxId: null,
spentIndex: null,
spentHeight: null
}
],
blockhash: "00000000e7232ff12462dedf9c11985f5b54202515277c337ccc59812758f28b",
blockheight: 1270188,
confirmations: 3,
time: 1543436253,
blocktime: 1543436253,
valueOut: 450.78867333,
size: 226,
valueIn: 450.78867559,
fees: 0.00000226
}
module.exports = {
mockDetails
}
+18
View File
@@ -0,0 +1,18 @@
/*
This library contains mocking data for running unit tests on the address route.
*/
"use strict"
const mockAddress = {
isvalid: true,
address: "bchtest:qqqk4y6lsl5da64sg5qc3xezmplyu5kmpyz2ysaa5y",
scriptPubKey: "76a914016a935f87e8deeab04501889b22d87e4e52db0988ac",
ismine: false,
iswatchonly: false,
isscript: false
}
module.exports = {
mockAddress
}