Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
rohenaz committed Jan 24, 2023
1 parent 4b88c0a commit 253f7b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bob.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,10 @@ func (t *Tx) ToTx() (*bt.Tx, error) {
if in.E.V != nil {
v = *in.E.V
}

// add inputs
i := &bt.Input{
PreviousTxOutIndex: in.E.I,
PreviousTxOutIndex: in.E.I, // TODO: This might be getting set incorrectly?
PreviousTxSatoshis: v,
PreviousTxScript: prevTxScript,
UnlockingScript: builtUnlockScript,
Expand Down
10 changes: 8 additions & 2 deletions bob_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package bob

import (
"encoding/hex"
"fmt"
"strings"
"testing"

"github.com/bitcoinschema/go-bitcoin/v2"
test "github.com/bitcoinschema/go-bob/testing"
"github.com/libsv/go-bt/v2"
"github.com/libsv/go-bt/v2/bscript"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -444,8 +446,12 @@ func TestTx_ToTx(t *testing.T) {
assert.Equal(t, len(bobTx.In), len(tx.Inputs))
assert.Equal(t, len(bobTx.Out), len(tx.Outputs))

// TODO: Why does this match? what is 48 and 21
assert.Equal(t, fmt.Sprintf("48%s21%s", *bobTx.In[0].Tape[0].Cell[0].H, *bobTx.In[0].Tape[0].Cell[1].H), tx.Inputs[0].UnlockingScript.String())
parts, err := bscript.DecodeParts(*tx.Inputs[0].UnlockingScript)
part0 := hex.EncodeToString(parts[0])
part1 := hex.EncodeToString(parts[1])
assert.Equal(t, *bobTx.In[0].Tape[0].Cell[0].H, part0)
assert.Equal(t, *bobTx.In[0].Tape[0].Cell[1].H, part1)

assert.Equal(t, bobTx.Tx.H, tx.TxID())
}

Expand Down

0 comments on commit 253f7b5

Please sign in to comment.