MCPcopy Create free account
hub / github.com/ElementsProject/elements / TestFillInputToWeight

Function TestFillInputToWeight

src/wallet/test/spend_tests.cpp:66–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66static void TestFillInputToWeight(int64_t additional_weight, std::vector<int64_t> expected_stack_sizes)
67{
68 CMutableTransaction mtx;
69 mtx.vin.resize(1);
70 mtx.witness.vtxinwit.resize(1);
71 static const int64_t EMPTY_INPUT_WEIGHT = GetTransactionInputWeight(CTransaction(mtx), 0);
72
73 CTxIn input;
74 int64_t target_weight = EMPTY_INPUT_WEIGHT + additional_weight;
75 size_t nIn{0};
76 BOOST_CHECK(FillInputToWeight(mtx, nIn, target_weight));
77 BOOST_CHECK_EQUAL(GetTransactionInputWeight(CTransaction(mtx), nIn), target_weight);
78 BOOST_CHECK_EQUAL(mtx.witness.vtxinwit[nIn].scriptWitness.stack.size(), expected_stack_sizes.size());
79 for (unsigned int i = 0; i < expected_stack_sizes.size(); ++i) {
80 BOOST_CHECK_EQUAL(mtx.witness.vtxinwit[nIn].scriptWitness.stack[i].size(), expected_stack_sizes[i]);
81 }
82}
83
84BOOST_FIXTURE_TEST_CASE(FillInputToWeightTest, BasicTestingSetup)
85{

Callers 1

BOOST_FIXTURE_TEST_CASEFunction · 0.85

Calls 5

FillInputToWeightFunction · 0.85
CTransactionClass · 0.50
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected