mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm/network/stream: unit test for prices
This commit is contained in:
parent
920b2a4250
commit
b3493cfc57
3 changed files with 29 additions and 3 deletions
|
|
@ -130,7 +130,6 @@ func SetupAccountingMetrics(reportInterval time.Duration, path string) *Accounti
|
|||
return NewAccountingMetrics(MetricsRegistry, reportInterval, path)
|
||||
}
|
||||
|
||||
// Implement Hook.Send
|
||||
// Send takes a peer, a size and a msg and
|
||||
// - calculates the cost for the local node sending a msg of size to peer using the Prices interface
|
||||
// - credits/debits local node using balance interface
|
||||
|
|
@ -150,7 +149,6 @@ func (ah *Accounting) Send(peer *Peer, size uint32, msg interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Implement Hook.Receive
|
||||
// Receive takes a peer, a size and a msg and
|
||||
// - calculates the cost for the local node receiving a msg of size from peer using the Prices interface
|
||||
// - credits/debits local node using balance interface
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ func NewRegistry(localID enode.ID, delivery *Delivery, syncChunkStore storage.Sy
|
|||
if options.SyncUpdateDelay <= 0 {
|
||||
options.SyncUpdateDelay = 15 * time.Second
|
||||
}
|
||||
// check if retriaval has been disabled
|
||||
// check if retrieval has been disabled
|
||||
retrieval := options.Retrieval != RetrievalDisabled
|
||||
|
||||
streamer := &Registry{
|
||||
|
|
|
|||
|
|
@ -921,3 +921,31 @@ func TestMaxPeerServersWithoutUnsubscribe(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRetrievalIsBilled(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHasPriceImplementation(t *testing.T) {
|
||||
_, r, _, teardown, err := newStreamerTester(t, &RegistryOptions{
|
||||
Retrieval: RetrievalDisabled,
|
||||
Syncing: SyncingDisabled,
|
||||
})
|
||||
defer teardown()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if r.prices == nil {
|
||||
t.Fatal("No prices implementation available for the stream protocol")
|
||||
}
|
||||
|
||||
price := r.prices.Price(&ChunkDeliveryMsgRetrieval{})
|
||||
if price == nil || price.Value == 0 {
|
||||
t.Fatal("No prices set for chunk delivery msg")
|
||||
}
|
||||
|
||||
price = r.prices.Price(&RetrieveRequestMsg{})
|
||||
if price == nil || price.Value == 0 {
|
||||
t.Fatal("No prices set for chunk delivery msg")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue