Skip to content

Commit

Permalink
Fix TestContractApplyChainUpdates NDF (#1450)
Browse files Browse the repository at this point in the history
This ensures the host has more than one spendable output to work with,
avoiding the NDF where it fails to fund a contract formation txn. This
PR also fixes the deadlock we've been seeing by passing a buffered error
channel to the host's volume manager.
  • Loading branch information
ChrisSchinnerl authored Aug 16, 2024
2 parents dc9e48b + 5ec92d0 commit 8118f9f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions internal/test/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,10 @@ func (c *TestCluster) AddHost(h *Host) {
c.hosts = append(c.hosts, h)

// Fund host from bus.
fundAmt := types.Siacoins(25e3)
c.tt.OKAll(c.Bus.SendSiacoins(context.Background(), h.WalletAddress(), fundAmt, true))
fundAmt := types.Siacoins(5e3)
for i := 0; i < 5; i++ {
c.tt.OKAll(c.Bus.SendSiacoins(context.Background(), h.WalletAddress(), fundAmt, true))
}

// Mine transaction.
c.MineBlocks(1)
Expand All @@ -834,8 +836,8 @@ func (c *TestCluster) AddHost(h *Host) {
c.tt.OK(addStorageFolderToHost(ctx, []*Host{h}))
c.tt.OK(announceHosts([]*Host{h}))

// Mine a few blocks. The host should show up eventually.
c.tt.Retry(10, time.Second, func() error {
// Mine until the host shows up.
c.tt.Retry(100, 100*time.Millisecond, func() error {
c.tt.Helper()

_, err := c.Bus.Host(context.Background(), h.PublicKey())
Expand Down
3 changes: 2 additions & 1 deletion internal/test/e2e/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,8 @@ func TestContractApplyChainUpdates(t *testing.T) {
// manually form a contract with the host
cs, _ := b.ConsensusState(context.Background())
wallet, _ := b.Wallet(context.Background())
rev, _, _ := w.RHPForm(context.Background(), cs.BlockHeight+test.AutopilotConfig.Contracts.Period+test.AutopilotConfig.Contracts.RenewWindow, h.PublicKey, h.NetAddress, wallet.Address, types.Siacoins(1), types.Siacoins(1))
rev, _, err := w.RHPForm(context.Background(), cs.BlockHeight+test.AutopilotConfig.Contracts.Period+test.AutopilotConfig.Contracts.RenewWindow, h.PublicKey, h.NetAddress, wallet.Address, types.Siacoins(1), types.Siacoins(1))
tt.OK(err)
contract, err := b.AddContract(context.Background(), rev, rev.Revision.MissedHostPayout().Sub(types.Siacoins(1)), types.Siacoins(1), cs.BlockHeight, api.ContractStatePending)
tt.OK(err)

Expand Down
2 changes: 1 addition & 1 deletion internal/test/e2e/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (h *Host) RHPv3Addr() string {

// AddVolume adds a new volume to the host
func (h *Host) AddVolume(ctx context.Context, path string, size uint64) error {
result := make(chan error)
result := make(chan error, 1)
_, err := h.storage.AddVolume(ctx, path, size, result)
if err != nil {
return err
Expand Down

0 comments on commit 8118f9f

Please sign in to comment.