WIP: next hard fork #5

Draft
BrannonKing wants to merge 178 commits from WIP-HF-2022 into master
2 changed files with 14 additions and 13 deletions
Showing only changes of commit 77660b7fb0 - Show all commits

View file

@ -327,3 +327,17 @@ func BenchmarkIsNullDataScript(b *testing.B) {
_ = IsNullData(script)
}
}
// BenchmarkIsUnspendable benchmarks how long it takes IsUnspendable to analyze
// a very large script.
func BenchmarkIsUnspendable(b *testing.B) {
script, err := genComplexScript()
if err != nil {
b.Fatalf("failed to create benchmark script: %v", err)
}
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = IsUnspendable(script)
}
}

View file

@ -4334,16 +4334,3 @@ func TestIsUnspendable(t *testing.T) {
}
}
}
// BenchmarkIsUnspendable adds a benchmark to compare the time and allocations
// necessary for the IsUnspendable function.
func BenchmarkIsUnspendable(b *testing.B) {
pkScriptToUse := []byte{0xa9, 0x14, 0x82, 0x1d, 0xba, 0x94, 0xbc, 0xfb, 0xa2, 0x57, 0x36, 0xa3, 0x9e, 0x5d, 0x14, 0x5d, 0x69, 0x75, 0xba, 0x8c, 0x0b, 0x42, 0x87}
var res bool = false
for i := 0; i < b.N; i++ {
res = IsUnspendable(pkScriptToUse)
}
if res {
b.Fatalf("Benchmark should never have res be %t\n", res)
}
}