From d886e76abd74c7133a2fab93426cfc93e87098a4 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 3 Jul 2018 22:33:22 +1000 Subject: [PATCH] tests/payments: add null data tests --- test/fixtures/p2data.json | 63 +++++++++++++++++++++++++++++++++++++++ test/payments.js | 2 +- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/p2data.json diff --git a/test/fixtures/p2data.json b/test/fixtures/p2data.json new file mode 100644 index 0000000..b0486cd --- /dev/null +++ b/test/fixtures/p2data.json @@ -0,0 +1,63 @@ +{ + "valid": [ + { + "description": "output from output", + "arguments": { + "output": "OP_RETURN a3b147dbe4a85579fc4b5a1811e76620560e07267e62b9a0d6858f9127735cadd82f67e06c24dbc4" + }, + "expected": { + "data": [ + "a3b147dbe4a85579fc4b5a1811e76620560e07267e62b9a0d6858f9127735cadd82f67e06c24dbc4" + ], + "output": "OP_RETURN a3b147dbe4a85579fc4b5a1811e76620560e07267e62b9a0d6858f9127735cadd82f67e06c24dbc4", + "input": null, + "witness": null + } + }, + { + "description": "output from data", + "arguments": { + "data": [ + "a3b147dbe4a85579fc4b5a1811e76620560e07267e62b9a0d6858f9127735cadd82f67e06c24dbc4" + ] + }, + "expected": { + "data": [ + "a3b147dbe4a85579fc4b5a1811e76620560e07267e62b9a0d6858f9127735cadd82f67e06c24dbc4" + ], + "output": "OP_RETURN a3b147dbe4a85579fc4b5a1811e76620560e07267e62b9a0d6858f9127735cadd82f67e06c24dbc4", + "input": null, + "witness": null + } + } + ], + "invalid": [ + { + "exception": "Not enough data", + "arguments": {} + } + ], + "dynamic": { + "depends": { + "data": [ "data", "output" ], + "output": [ "output", "data" ] + }, + "details": [ + { + "description": "p2data", + "data": [ + "a3b147dbe4a85579fc4b5a1811e76620560e07267e62b9a0d6858f9127735cadd82f67e06c24dbc4" + ], + "output": "OP_RETURN a3b147dbe4a85579fc4b5a1811e76620560e07267e62b9a0d6858f9127735cadd82f67e06c24dbc4" + }, + { + "description": "p2data", + "data": [ + "a3b147dbe4a85579fc4b5a1811e76620560e0726", + "7e62b9a0d6858f9127735cadd82f67e06c24dbc4" + ], + "output": "OP_RETURN a3b147dbe4a85579fc4b5a1811e76620560e0726 7e62b9a0d6858f9127735cadd82f67e06c24dbc4" + } + ] + } +} diff --git a/test/payments.js b/test/payments.js index 6a4e733..3645ea7 100644 --- a/test/payments.js +++ b/test/payments.js @@ -3,7 +3,7 @@ const assert = require('assert') const u = require('./payments.utils') -;['p2ms', 'p2pk', 'p2pkh', 'p2sh', 'p2wpkh', 'p2wsh'].forEach(function (p) { +;['p2data', 'p2ms', 'p2pk', 'p2pkh', 'p2sh', 'p2wpkh', 'p2wsh'].forEach(function (p) { describe(p, function () { const fn = require('../src/payments/' + p) const fixtures = require('./fixtures/' + p)