From 118f548033116c0c24eff71825118363144aa7f9 Mon Sep 17 00:00:00 2001 From: Luke Rohenaz Date: Fri, 3 Mar 2023 15:55:27 -0500 Subject: [PATCH] add boost test. update go-bpu and added require for parseconfig --- bob.go | 1 + bob_test.go | 19 ++++++++++++++++++- go.mod | 4 +--- go.sum | 4 ++-- ...55908a7c572296e803512e497ddf7d1f458bd3.hex | 1 + 5 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 testing/tx/c5c7248302683107aa91014fd955908a7c572296e803512e497ddf7d1f458bd3.hex diff --git a/bob.go b/bob.go index 68551b1..953b452 100644 --- a/bob.go +++ b/bob.go @@ -160,6 +160,7 @@ func (t *Tx) FromRawTxString(rawTxString string) (err error) { Token: &bpu.Token{ S: &separator, }, + Require: &opReturn, }, } diff --git a/bob_test.go b/bob_test.go index ab47445..deca747 100644 --- a/bob_test.go +++ b/bob_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/assert" ) -var sampleBobTx, sampleBobTxBadStrings, rawBobTx, parityBob, parityTx string +var sampleBobTx, sampleBobTxBadStrings, rawBobTx, parityBob, parityTx, boostTx string func init() { sampleBobTx = test.GetTestHex("./testing/bob/207eaadc096849e037b8944df21a8bba6d91d8445848db047c0a3f963121e19d.json") @@ -22,6 +22,7 @@ func init() { rawBobTx = test.GetTestHex("./testing/tx/2.hex") parityBob = test.GetTestHex("./testing/bob/98a5f6ef18eaea188bdfdc048f89a48af82627a15a76fd53584975f28ab3cc39.json") parityTx = test.GetTestHex("./testing/tx/98a5f6ef18eaea188bdfdc048f89a48af82627a15a76fd53584975f28ab3cc39.hex") + boostTx = test.GetTestHex("./testing/tx/c5c7248302683107aa91014fd955908a7c572296e803512e497ddf7d1f458bd3.hex") } // TestNewFromBytes tests for nil case in NewFromBytes() @@ -619,6 +620,22 @@ func TestTx_ToString2(t *testing.T) { } +// Test Boost + +func TestTx_Boost(t *testing.T) { + // import a tx from hex + goBobTx, err := NewFromRawTxString(boostTx) + assert.NoError(t, err) + + if _, err = goBobTx.ToString(); err != nil { + fmt.Printf("error occurred: %s", err.Error()) + } + assert.NoError(t, err) + + assert.Equal(t, 89, len(goBobTx.Out[0].Tape[0].Cell)) +} + +// c5c7248302683107aa91014fd955908a7c572296e803512e497ddf7d1f458bd3 // BenchmarkTx_ToString benchmarks the method ToString() func BenchmarkTx_ToString(b *testing.B) { bobTx, _ := NewFromString(sampleBobTx) diff --git a/go.mod b/go.mod index 79d874a..797784f 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( require github.com/kr/pretty v0.3.1 // indirect require ( - github.com/bitcoinschema/go-bpu v0.0.3 + github.com/bitcoinschema/go-bpu v0.0.4 github.com/bitcoinsv/bsvd v0.0.0-20190609155523-4c29707f7173 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/libsv/go-bk v0.1.6 // indirect @@ -20,5 +20,3 @@ require ( golang.org/x/crypto v0.6.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -// replace github.com/libsv/go-bt => github.com/libsv/go-bt v1.0.4 diff --git a/go.sum b/go.sum index 5a17c38..66b404d 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/bitcoinschema/go-bitcoin/v2 v2.0.3 h1:3pxGpFk7L2GcAx6VYW6kgcOmI0jhnZ/2zKSsfxqhvfM= github.com/bitcoinschema/go-bitcoin/v2 v2.0.3/go.mod h1:MnikSx/hRXOS7dG3RlJOP2cV2lG6IOmoGd6HhvCB7Gc= -github.com/bitcoinschema/go-bpu v0.0.3 h1:Lz5BU36DYmod0lVPrMFO2NIG650PXRcC6e3SQhvpeeQ= -github.com/bitcoinschema/go-bpu v0.0.3/go.mod h1:i41D9NP5KIk/oCt8XrRhN27YerZCUG6vjScXDhNn5Us= +github.com/bitcoinschema/go-bpu v0.0.4 h1:EapuVhZcRD8ZOqBCcHUdzaMGOUmabvuXc6EvONBn5Mc= +github.com/bitcoinschema/go-bpu v0.0.4/go.mod h1:i41D9NP5KIk/oCt8XrRhN27YerZCUG6vjScXDhNn5Us= github.com/bitcoinsv/bsvd v0.0.0-20190609155523-4c29707f7173 h1:2yTIV9u7H0BhRDGXH5xrAwAz7XibWJtX2dNezMeNsUo= github.com/bitcoinsv/bsvd v0.0.0-20190609155523-4c29707f7173/go.mod h1:BZ1UcC9+tmcDEcdVXgpt13hMczwJxWzpAn68wNs7zRA= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= diff --git a/testing/tx/c5c7248302683107aa91014fd955908a7c572296e803512e497ddf7d1f458bd3.hex b/testing/tx/c5c7248302683107aa91014fd955908a7c572296e803512e497ddf7d1f458bd3.hex new file mode 100644 index 0000000..a4ddaf6 --- /dev/null +++ b/testing/tx/c5c7248302683107aa91014fd955908a7c572296e803512e497ddf7d1f458bd3.hex @@ -0,0 +1 @@ +0100000001e0ea284dbd5bac08e09c02ed3453b640e0fcd4d0b4cdeb3457002c6a78bea8f1000000006a4730440220221e92fad96878479cc637ae490eef446bf2903eaa8690c0f08f34f40da8c59e02200c2af911c1750720e9ef1056a791cbae8f344a3ff5800805ef95a387506f9c714121035cdc1e244b8dad15bf688ffef35450be993558f4345ebf9241727ccb669cc2fbffffffff02a086010000000000cf08626f6f7374706f7775045704000020d8d083b2d51f0652785201324105d3c39c662fa44062ccedacf883528b803273049cff631d067468656f727904890000001c746869732069732074686520426f6f737420776869746570617065727e7c557a766b7e52796b557a8254887e557a8258887e7c7eaa7c6b7e7e7c8254887e6c7e7c8254887eaa01007e816c825488537f7681530121a5696b768100a0691d00000000000000000000000000000000000000000000000000000000007e6c539458959901007e819f6976a96c88ac74ba0d00000000001976a914ed5bf460b28f7c7f1aff14737a4ec5277c83a8eb88ac1ee90b00 \ No newline at end of file