@@ -117,7 +117,8 @@ BOOST_FIXTURE_TEST_CASE(ephemeral_tests, RegTestingSetup)
117
117
TestMemPoolEntryHelper entry;
118
118
CTxMemPool::setEntries empty_ancestors;
119
119
120
- CFeeRate minrelay (1000 );
120
+ // Arbitrary non-0 feerate for these tests
121
+ CFeeRate dustrelay (DUST_RELAY_TX_FEE);
121
122
122
123
// Basic transaction with dust
123
124
auto grandparent_tx_1 = make_ephemeral_tx (random_outpoints (1 ), /* version=*/ 2 );
@@ -129,88 +130,88 @@ BOOST_FIXTURE_TEST_CASE(ephemeral_tests, RegTestingSetup)
129
130
// We first start with nothing "in the mempool", using package checks
130
131
131
132
// Trivial single transaction with no dust
132
- BOOST_CHECK (!CheckEphemeralSpends ({dust_spend}, minrelay , pool));
133
+ BOOST_CHECK (!CheckEphemeralSpends ({dust_spend}, dustrelay , pool));
133
134
134
135
// Now with dust, ok because the tx has no dusty parents
135
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1}, minrelay , pool));
136
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1}, dustrelay , pool));
136
137
137
138
// Dust checks pass
138
139
BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, dust_spend}, CFeeRate (0 ), pool));
139
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, dust_spend}, minrelay , pool));
140
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, dust_spend}, dustrelay , pool));
140
141
141
142
auto dust_non_spend = make_tx ({COutPoint{dust_txid, EPHEMERAL_DUST_INDEX - 1 }}, /* version=*/ 2 );
142
143
143
144
// Child spending non-dust only from parent should be disallowed even if dust otherwise spent
144
145
const auto dust_non_spend_txid{dust_non_spend->GetHash ()};
145
146
const Txid null_txid;
146
147
assert (dust_non_spend_txid != null_txid);
147
- BOOST_CHECK_EQUAL (CheckEphemeralSpends ({grandparent_tx_1, dust_non_spend, dust_spend}, minrelay , pool).value_or (null_txid), dust_non_spend_txid);
148
- BOOST_CHECK_EQUAL (CheckEphemeralSpends ({grandparent_tx_1, dust_spend, dust_non_spend}, minrelay , pool).value_or (null_txid), dust_non_spend_txid);
149
- BOOST_CHECK_EQUAL (CheckEphemeralSpends ({grandparent_tx_1, dust_non_spend}, minrelay , pool).value_or (null_txid), dust_non_spend_txid);
148
+ BOOST_CHECK_EQUAL (CheckEphemeralSpends ({grandparent_tx_1, dust_non_spend, dust_spend}, dustrelay , pool).value_or (null_txid), dust_non_spend_txid);
149
+ BOOST_CHECK_EQUAL (CheckEphemeralSpends ({grandparent_tx_1, dust_spend, dust_non_spend}, dustrelay , pool).value_or (null_txid), dust_non_spend_txid);
150
+ BOOST_CHECK_EQUAL (CheckEphemeralSpends ({grandparent_tx_1, dust_non_spend}, dustrelay , pool).value_or (null_txid), dust_non_spend_txid);
150
151
151
152
auto grandparent_tx_2 = make_ephemeral_tx (random_outpoints (1 ), /* version=*/ 2 );
152
153
const auto dust_txid_2 = grandparent_tx_2->GetHash ();
153
154
154
155
// Spend dust from one but not another is ok, as long as second grandparent has no child
155
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend}, minrelay , pool));
156
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend}, dustrelay , pool));
156
157
157
158
auto dust_non_spend_both_parents = make_tx ({COutPoint{dust_txid, EPHEMERAL_DUST_INDEX}, COutPoint{dust_txid_2, EPHEMERAL_DUST_INDEX - 1 }}, /* version=*/ 2 );
158
159
// But if we spend from the parent, it must spend dust
159
- BOOST_CHECK_EQUAL (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_non_spend_both_parents}, minrelay , pool).value_or (null_txid), dust_non_spend_both_parents->GetHash ());
160
+ BOOST_CHECK_EQUAL (CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_non_spend_both_parents}, dustrelay , pool).value_or (null_txid), dust_non_spend_both_parents->GetHash ());
160
161
161
162
auto dust_spend_both_parents = make_tx ({COutPoint{dust_txid, EPHEMERAL_DUST_INDEX}, COutPoint{dust_txid_2, EPHEMERAL_DUST_INDEX}}, /* version=*/ 2 );
162
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend_both_parents}, minrelay , pool));
163
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend_both_parents}, dustrelay , pool));
163
164
164
165
// Spending other outputs is also correct, as long as the dusty one is spent
165
166
const std::vector<COutPoint> all_outpoints{COutPoint (dust_txid, 0 ), COutPoint (dust_txid, 1 ), COutPoint (dust_txid, 2 ),
166
167
COutPoint (dust_txid_2, 0 ), COutPoint (dust_txid_2, 1 ), COutPoint (dust_txid_2, 2 )};
167
168
auto dust_spend_all_outpoints = make_tx (all_outpoints, /* version=*/ 2 );
168
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend_all_outpoints}, minrelay , pool));
169
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, dust_spend_all_outpoints}, dustrelay , pool));
169
170
170
171
// 2 grandparents with dust <- 1 dust-spending parent with dust <- child with no dust
171
172
auto parent_with_dust = make_ephemeral_tx ({COutPoint{dust_txid, EPHEMERAL_DUST_INDEX}, COutPoint{dust_txid_2, EPHEMERAL_DUST_INDEX}}, /* version=*/ 2 );
172
173
// Ok for parent to have dust
173
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust}, minrelay , pool));
174
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust}, dustrelay , pool));
174
175
auto child_no_dust = make_tx ({COutPoint{parent_with_dust->GetHash (), EPHEMERAL_DUST_INDEX}}, /* version=*/ 2 );
175
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust, child_no_dust}, minrelay , pool));
176
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust, child_no_dust}, dustrelay , pool));
176
177
177
178
// 2 grandparents with dust <- 1 dust-spending parent with dust <- child with dust
178
179
auto child_with_dust = make_ephemeral_tx ({COutPoint{parent_with_dust->GetHash (), EPHEMERAL_DUST_INDEX}}, /* version=*/ 2 );
179
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust, child_with_dust}, minrelay , pool));
180
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1, grandparent_tx_2, parent_with_dust, child_with_dust}, dustrelay , pool));
180
181
181
182
// Tests with parents in mempool
182
183
183
184
// Nothing in mempool, this should pass for any transaction
184
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1}, minrelay , pool));
185
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_1}, dustrelay , pool));
185
186
186
187
// Add first grandparent to mempool and fetch entry
187
188
pool.addUnchecked (entry.FromTx (grandparent_tx_1));
188
189
189
190
// Ignores ancestors that aren't direct parents
190
- BOOST_CHECK (!CheckEphemeralSpends ({child_no_dust}, minrelay , pool));
191
+ BOOST_CHECK (!CheckEphemeralSpends ({child_no_dust}, dustrelay , pool));
191
192
192
193
// Valid spend of dust with grandparent in mempool
193
- BOOST_CHECK (!CheckEphemeralSpends ({parent_with_dust}, minrelay , pool));
194
+ BOOST_CHECK (!CheckEphemeralSpends ({parent_with_dust}, dustrelay , pool));
194
195
195
196
// Second grandparent in same package
196
- BOOST_CHECK (!CheckEphemeralSpends ({parent_with_dust, grandparent_tx_2}, minrelay , pool));
197
+ BOOST_CHECK (!CheckEphemeralSpends ({parent_with_dust, grandparent_tx_2}, dustrelay , pool));
197
198
// Order in package doesn't matter
198
- BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_2, parent_with_dust}, minrelay , pool));
199
+ BOOST_CHECK (!CheckEphemeralSpends ({grandparent_tx_2, parent_with_dust}, dustrelay , pool));
199
200
200
201
// Add second grandparent to mempool
201
202
pool.addUnchecked (entry.FromTx (grandparent_tx_2));
202
203
203
204
// Only spends single dust out of two direct parents
204
- BOOST_CHECK_EQUAL (CheckEphemeralSpends ({dust_non_spend_both_parents}, minrelay , pool).value_or (null_txid), dust_non_spend_both_parents->GetHash ());
205
+ BOOST_CHECK_EQUAL (CheckEphemeralSpends ({dust_non_spend_both_parents}, dustrelay , pool).value_or (null_txid), dust_non_spend_both_parents->GetHash ());
205
206
206
207
// Spends both parents' dust
207
- BOOST_CHECK (!CheckEphemeralSpends ({parent_with_dust}, minrelay , pool));
208
+ BOOST_CHECK (!CheckEphemeralSpends ({parent_with_dust}, dustrelay , pool));
208
209
209
210
// Now add dusty parent to mempool
210
211
pool.addUnchecked (entry.FromTx (parent_with_dust));
211
212
212
213
// Passes dust checks even with non-parent ancestors
213
- BOOST_CHECK (!CheckEphemeralSpends ({child_no_dust}, minrelay , pool));
214
+ BOOST_CHECK (!CheckEphemeralSpends ({child_no_dust}, dustrelay , pool));
214
215
}
215
216
216
217
BOOST_FIXTURE_TEST_CASE (version3_tests, RegTestingSetup)
0 commit comments