本文整理匯總了Golang中github.com/NebulousLabs/Sia/modules.HostDBEntry.StoragePrice方法的典型用法代碼示例。如果您正苦於以下問題:Golang HostDBEntry.StoragePrice方法的具體用法?Golang HostDBEntry.StoragePrice怎麽用?Golang HostDBEntry.StoragePrice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/NebulousLabs/Sia/modules.HostDBEntry
的用法示例。
在下文中一共展示了HostDBEntry.StoragePrice方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestEditor
// TestEditor tests the failure conditions of the Editor method. The method is
// more fully tested in the host integration test.
func TestEditor(t *testing.T) {
// use a mock hostdb to supply hosts
hdb := &editorHostDB{
hosts: make(map[modules.NetAddress]modules.HostDBEntry),
}
c := &Contractor{
hdb: hdb,
}
// empty contract
_, err := c.Editor(modules.RenterContract{})
if err == nil {
t.Error("expected error, got nil")
}
// expired contract
c.blockHeight = 3
_, err = c.Editor(modules.RenterContract{})
if err == nil {
t.Error("expected error, got nil")
}
c.blockHeight = 0
// expensive host
_, hostPublicKey := crypto.GenerateKeyPairDeterministic([32]byte{})
dbe := modules.HostDBEntry{
PublicKey: types.SiaPublicKey{
Algorithm: types.SignatureEd25519,
Key: hostPublicKey[:],
},
}
dbe.AcceptingContracts = true
dbe.StoragePrice = types.NewCurrency64(^uint64(0))
hdb.hosts["foo"] = dbe
_, err = c.Editor(modules.RenterContract{NetAddress: "foo"})
if err == nil {
t.Error("expected error, got nil")
}
// invalid contract
dbe.StoragePrice = types.NewCurrency64(500)
hdb.hosts["bar"] = dbe
_, err = c.Editor(modules.RenterContract{NetAddress: "bar"})
if err == nil {
t.Error("expected error, got nil")
}
// spent contract
contract := modules.RenterContract{
NetAddress: "bar",
LastRevision: types.FileContractRevision{
NewValidProofOutputs: []types.SiacoinOutput{
{Value: types.NewCurrency64(0)},
{Value: types.NewCurrency64(^uint64(0))},
},
},
}
_, err = c.Editor(contract)
if err == nil {
t.Error("expected error, got nil")
}
}