gcs/builder: fix tests by rebuilding filter, making failure to match fatal

This commit is contained in:
Alex 2017-10-27 16:26:35 -06:00 committed by Olaoluwa Osuntokun
parent dabaf053db
commit 03a7f9b01f

View file

@ -261,7 +261,7 @@ func BuilderTest(b *builder.GCSBuilder, hash *chainhash.Hash, p uint8,
}
pushedData, err := txscript.PushedData(addrBytes)
if err != nil {
t.Fatalf("Couldn't extract pushed data from addrBytesess script: %s",
t.Fatalf("Couldn't extract pushed data from addrBytes script: %s",
err.Error())
}
match, err = f.MatchAny(key, pushedData)
@ -269,17 +269,21 @@ func BuilderTest(b *builder.GCSBuilder, hash *chainhash.Hash, p uint8,
t.Fatalf("Filter match any failed: %s", err)
}
if !match {
t.Logf("Filter didn't match when it should have!")
t.Fatal("Filter didn't match when it should have!")
}
// Add a routine witness stack, build a filter, and test that it
// matches.
b.AddWitness(witness)
f, err = b.Build()
if err != nil {
t.Fatalf("Filter build failed: %s", err.Error())
}
match, err = f.MatchAny(key, witness)
if err != nil {
t.Fatalf("Filter match any failed: %s", err)
}
if !match {
t.Logf("Filter didn't match when it should have!")
t.Fatal("Filter didn't match when it should have!")
}
}