@@ -1135,9 +1135,10 @@ mod tests {
1135
1135
. verify_schnorr ( & schnorr_sig. sig , & sighash, xpk)
1136
1136
. is_ok ( ) ,
1137
1137
} ;
1138
-
1138
+ let fixed_hash : & sha256 :: Hash = & sha256 :: Hash :: from_inner ( [ 34u8 ; 32 ] ) ;
1139
1139
fn from_stack < ' txin , ' elem > (
1140
1140
verify_fn : Box < dyn FnMut ( & KeySigPair ) -> bool + ' elem > ,
1141
+ fixed_hash : & ' elem sha256:: Hash ,
1141
1142
stack : Stack < ' txin > ,
1142
1143
ms : & ' elem Miniscript < BitcoinKey , NoChecks > ,
1143
1144
) -> Iter < ' elem , ' txin > {
@@ -1153,6 +1154,8 @@ mod tests {
1153
1154
age : 1002 ,
1154
1155
height : 1002 ,
1155
1156
has_errored : false ,
1157
+ // TODO: Replace with actual hash
1158
+ txtemplate : & fixed_hash,
1156
1159
}
1157
1160
}
1158
1161
@@ -1177,7 +1180,7 @@ mod tests {
1177
1180
1178
1181
let stack = Stack :: from ( vec ! [ stack:: Element :: Push ( & der_sigs[ 0 ] ) ] ) ;
1179
1182
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1180
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & pk) ;
1183
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & pk) ;
1181
1184
let pk_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1182
1185
assert_eq ! (
1183
1186
pk_satisfied. unwrap( ) ,
@@ -1189,7 +1192,7 @@ mod tests {
1189
1192
//Check Pk failure with wrong signature
1190
1193
let stack = Stack :: from ( vec ! [ stack:: Element :: Dissatisfied ] ) ;
1191
1194
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1192
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & pk) ;
1195
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & pk) ;
1193
1196
let pk_err: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1194
1197
assert ! ( pk_err. is_err( ) ) ;
1195
1198
@@ -1200,7 +1203,7 @@ mod tests {
1200
1203
stack:: Element :: Push ( & pk_bytes) ,
1201
1204
] ) ;
1202
1205
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1203
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & pkh) ;
1206
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & pkh) ;
1204
1207
let pkh_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1205
1208
assert_eq ! (
1206
1209
pkh_satisfied. unwrap( ) ,
@@ -1213,7 +1216,7 @@ mod tests {
1213
1216
//Check After
1214
1217
let stack = Stack :: from ( vec ! [ ] ) ;
1215
1218
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1216
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & after) ;
1219
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & after) ;
1217
1220
let after_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1218
1221
assert_eq ! (
1219
1222
after_satisfied. unwrap( ) ,
@@ -1223,7 +1226,7 @@ mod tests {
1223
1226
//Check Older
1224
1227
let stack = Stack :: from ( vec ! [ ] ) ;
1225
1228
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1226
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & older) ;
1229
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & older) ;
1227
1230
let older_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1228
1231
assert_eq ! (
1229
1232
older_satisfied. unwrap( ) ,
@@ -1233,7 +1236,7 @@ mod tests {
1233
1236
//Check Sha256
1234
1237
let stack = Stack :: from ( vec ! [ stack:: Element :: Push ( & preimage) ] ) ;
1235
1238
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1236
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & sha256) ;
1239
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & sha256) ;
1237
1240
let sah256_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1238
1241
assert_eq ! (
1239
1242
sah256_satisfied. unwrap( ) ,
@@ -1246,7 +1249,7 @@ mod tests {
1246
1249
//Check Shad256
1247
1250
let stack = Stack :: from ( vec ! [ stack:: Element :: Push ( & preimage) ] ) ;
1248
1251
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1249
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & hash256) ;
1252
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & hash256) ;
1250
1253
let sha256d_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1251
1254
assert_eq ! (
1252
1255
sha256d_satisfied. unwrap( ) ,
@@ -1259,7 +1262,7 @@ mod tests {
1259
1262
//Check hash160
1260
1263
let stack = Stack :: from ( vec ! [ stack:: Element :: Push ( & preimage) ] ) ;
1261
1264
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1262
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & hash160) ;
1265
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & hash160) ;
1263
1266
let hash160_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1264
1267
assert_eq ! (
1265
1268
hash160_satisfied. unwrap( ) ,
@@ -1272,7 +1275,7 @@ mod tests {
1272
1275
//Check ripemd160
1273
1276
let stack = Stack :: from ( vec ! [ stack:: Element :: Push ( & preimage) ] ) ;
1274
1277
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1275
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & ripemd160) ;
1278
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & ripemd160) ;
1276
1279
let ripemd160_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1277
1280
assert_eq ! (
1278
1281
ripemd160_satisfied. unwrap( ) ,
@@ -1295,7 +1298,7 @@ mod tests {
1295
1298
pks[ 1 ] . to_pubkeyhash( )
1296
1299
) ) ;
1297
1300
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1298
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1301
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1299
1302
1300
1303
let and_v_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1301
1304
assert_eq ! (
@@ -1321,7 +1324,7 @@ mod tests {
1321
1324
pks[ 0 ] , sha256_hash
1322
1325
) ) ;
1323
1326
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1324
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1327
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1325
1328
1326
1329
let and_b_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1327
1330
assert_eq ! (
@@ -1349,7 +1352,7 @@ mod tests {
1349
1352
pks[ 1 ] . to_pubkeyhash( ) ,
1350
1353
) ) ;
1351
1354
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1352
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1355
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1353
1356
1354
1357
let and_or_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1355
1358
assert_eq ! (
@@ -1373,7 +1376,7 @@ mod tests {
1373
1376
stack:: Element :: Dissatisfied ,
1374
1377
] ) ;
1375
1378
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1376
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1379
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1377
1380
1378
1381
let and_or_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1379
1382
assert_eq ! (
@@ -1394,7 +1397,7 @@ mod tests {
1394
1397
pks[ 0 ] , sha256_hash
1395
1398
) ) ;
1396
1399
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1397
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1400
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1398
1401
1399
1402
let or_b_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1400
1403
assert_eq ! (
@@ -1412,7 +1415,7 @@ mod tests {
1412
1415
pks[ 0 ] , sha256_hash
1413
1416
) ) ;
1414
1417
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1415
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1418
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1416
1419
1417
1420
let or_d_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1418
1421
assert_eq ! (
@@ -1432,7 +1435,7 @@ mod tests {
1432
1435
sha256_hash, pks[ 0 ]
1433
1436
) ) ;
1434
1437
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1435
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1438
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1436
1439
1437
1440
let or_c_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1438
1441
assert_eq ! (
@@ -1452,7 +1455,7 @@ mod tests {
1452
1455
sha256_hash, pks[ 0 ]
1453
1456
) ) ;
1454
1457
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1455
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1458
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1456
1459
1457
1460
let or_i_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1458
1461
assert_eq ! (
@@ -1475,7 +1478,7 @@ mod tests {
1475
1478
pks[ 4 ] , pks[ 3 ] , pks[ 2 ] , pks[ 1 ] , pks[ 0 ] ,
1476
1479
) ) ;
1477
1480
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1478
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1481
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1479
1482
1480
1483
let thresh_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1481
1484
assert_eq ! (
@@ -1505,7 +1508,7 @@ mod tests {
1505
1508
pks[ 4 ] , pks[ 3 ] , pks[ 2 ] , pks[ 1 ] , pks[ 0 ] ,
1506
1509
) ) ;
1507
1510
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1508
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1511
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1509
1512
1510
1513
let multi_satisfied: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1511
1514
assert_eq ! (
@@ -1535,7 +1538,7 @@ mod tests {
1535
1538
pks[ 4 ] , pks[ 3 ] , pks[ 2 ] , pks[ 1 ] , pks[ 0 ] ,
1536
1539
) ) ;
1537
1540
let vfyfn = vfyfn_. clone ( ) ; // sigh rust 1.29...
1538
- let constraints = from_stack ( Box :: new ( vfyfn) , stack, & elem) ;
1541
+ let constraints = from_stack ( Box :: new ( vfyfn) , fixed_hash , stack, & elem) ;
1539
1542
1540
1543
let multi_error: Result < Vec < SatisfiedConstraint > , Error > = constraints. collect ( ) ;
1541
1544
assert ! ( multi_error. is_err( ) ) ;
0 commit comments