-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
447b3d1
commit caeb895
Showing
2 changed files
with
53 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package node | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"go.sia.tech/core/types" | ||
) | ||
|
||
func TestUnconfirmedParents(t *testing.T) { | ||
grandparent := types.Transaction{ | ||
SiacoinOutputs: []types.SiacoinOutput{{}}, | ||
} | ||
parent := types.Transaction{ | ||
SiacoinInputs: []types.SiacoinInput{ | ||
{ | ||
ParentID: grandparent.SiacoinOutputID(0), | ||
}, | ||
}, | ||
SiacoinOutputs: []types.SiacoinOutput{{}}, | ||
} | ||
txn := types.Transaction{ | ||
SiacoinInputs: []types.SiacoinInput{ | ||
{ | ||
ParentID: parent.SiacoinOutputID(0), | ||
}, | ||
}, | ||
SiacoinOutputs: []types.SiacoinOutput{{}}, | ||
} | ||
pool := []types.Transaction{grandparent, parent} | ||
|
||
parents := unconfirmedParents(txn, pool) | ||
if len(parents) != 2 { | ||
t.Fatalf("expected 2 parents, got %v", len(parents)) | ||
Check failure on line 34 in internal/node/transactionpool_test.go GitHub Actions / test (ubuntu-latest, 1.21)Test go.sia.tech/renterd/internal/node/TestUnconfirmedParents failed in 0s
|
||
} else if !reflect.DeepEqual(parents[0], grandparent) { | ||
t.Fatalf("expected grandparent") | ||
} else if !reflect.DeepEqual(parents[1], parent) { | ||
t.Fatalf("expected parent") | ||
} | ||
} |