Commit d2f9d9da authored by Luke Champine's avatar Luke Champine

Merge branch 'TestExhaustedContracts-ndf' into 'master'

Remove TestExhaustedContracts because of TestRenterContracts

Closes #3323

See merge request !3343
parents 7d170c85 60349464
Pipeline #38418765 passed with stages
in 34 minutes and 15 seconds
......@@ -1718,111 +1718,6 @@ func TestContractorHostRemoval(t *testing.T) {
}
}
// TestExhaustedContracts verifies that the contractor renews contracts which
// run out of funds before the period elapses.
func TestExhaustedContracts(t *testing.T) {
if testing.Short() || !build.VLONG {
t.SkipNow()
}
t.Parallel()
st, err := createServerTester(t.Name())
if err != nil {
t.Fatal(err)
}
defer st.server.panicClose()
// set a very high price for the host so we use up the entire funds of the
// contract
err = st.acceptContracts()
if err != nil {
t.Fatal(err)
}
err = st.setHostStorage()
if err != nil {
t.Fatal(err)
}
// Increase the storage and bandwidth prices to drain the allowance faster.
settings := st.host.InternalSettings()
settings.MinUploadBandwidthPrice = settings.MinUploadBandwidthPrice.Mul64(2)
settings.MinStoragePrice = settings.MinUploadBandwidthPrice.Mul64(2)
settings.MaxDuration = 1e6 // set a high max duration to allow an expensive storage price
err = st.host.SetInternalSettings(settings)
if err != nil {
t.Fatal(err)
}
err = st.announceHost()
if err != nil {
t.Fatal(err)
}
// Set an allowance for the renter, allowing a contract to be formed.
allowanceValues := url.Values{}
testPeriod := "950000" // large period to cause an expensive test, exhausting the allowance faster
allowanceValues.Set("funds", types.SiacoinPrecision.Mul64(10).String())
allowanceValues.Set("period", testPeriod)
err = st.stdPostAPI("/renter", allowanceValues)
if err != nil {
t.Fatal(err)
}
// wait until we have a contract
err = build.Retry(500, time.Millisecond*50, func() error {
if len(st.renter.Contracts()) >= 1 {
return nil
}
return errors.New("no renter contracts")
})
if err != nil {
t.Fatal(err)
}
initialContract := st.renter.Contracts()[0]
// upload a file. the high upload cost will cause the underlying contract to
// require premature renewal. If premature renewal never happens, the upload
// will never complete.
path := filepath.Join(st.dir, "randUploadFile")
size := int(modules.SectorSize * 75)
err = createRandFile(path, size)
if err != nil {
t.Fatal(err)
}
uploadValues := url.Values{}
uploadValues.Set("source", path)
uploadValues.Set("renew", "true")
uploadValues.Set("datapieces", "1")
uploadValues.Set("paritypieces", "1")
err = st.stdPostAPI("/renter/upload/"+filepath.Base(path), uploadValues)
if err != nil {
t.Fatal(err)
}
err = build.Retry(100, time.Millisecond*500, func() error {
// mine blocks each iteration to trigger contract maintenance
_, err = st.miner.AddBlock()
if err != nil {
t.Fatal(err)
}
st.miner.AddBlock()
if !st.renter.FileList()[0].Available {
return errors.New("file did not complete uploading")
}
return nil
})
if err != nil {
t.Fatal(err)
}
// verify that the window did not change and the contract ID did change
newContract := st.renter.Contracts()[0]
endHeight := newContract.EndHeight
if newContract.ID == initialContract.ID {
t.Error("renew did not occur")
}
if endHeight != initialContract.EndHeight {
t.Error("contract end height changed, wanted", initialContract.EndHeight, "got", endHeight)
}
}
// TestAdversarialPriceRenewal verifies that host cannot maliciously raise
// their storage price in order to trigger a premature file contract renewal.
func TestAdversarialPriceRenewal(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment