Refactor test code to better test JSDescription::Randomized()
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include "primitives/transaction.h"
|
||||
|
||||
#include "hash.h"
|
||||
#include "random.h"
|
||||
#include "tinyformat.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
@@ -52,13 +51,14 @@ JSDescription JSDescription::Randomized(
|
||||
boost::array<size_t, ZC_NUM_JS_OUTPUTS>& outputMap,
|
||||
CAmount vpub_old,
|
||||
CAmount vpub_new,
|
||||
bool computeProof)
|
||||
bool computeProof,
|
||||
std::function<int(int)> gen)
|
||||
{
|
||||
// Randomize the order of the inputs and outputs
|
||||
inputMap = {0, 1};
|
||||
outputMap = {0, 1};
|
||||
MappedShuffle(inputs.begin(), inputMap.begin(), ZC_NUM_JS_INPUTS, GetRandInt);
|
||||
MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, GetRandInt);
|
||||
MappedShuffle(inputs.begin(), inputMap.begin(), ZC_NUM_JS_INPUTS, gen);
|
||||
MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen);
|
||||
|
||||
return JSDescription(
|
||||
params, pubKeyHash, anchor, inputs, outputs,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#define BITCOIN_PRIMITIVES_TRANSACTION_H
|
||||
|
||||
#include "amount.h"
|
||||
#include "random.h"
|
||||
#include "script/script.h"
|
||||
#include "serialize.h"
|
||||
#include "uint256.h"
|
||||
@@ -88,7 +89,8 @@ public:
|
||||
boost::array<size_t, ZC_NUM_JS_OUTPUTS>& outputMap,
|
||||
CAmount vpub_old,
|
||||
CAmount vpub_new,
|
||||
bool computeProof = true // Set to false in some tests
|
||||
bool computeProof = true, // Set to false in some tests
|
||||
std::function<int(int)> gen = GetRandInt
|
||||
);
|
||||
|
||||
// Verifies that the JoinSplit proof is correct.
|
||||
|
||||
Reference in New Issue
Block a user