parent
8b9711cb5e
commit
67306d296b
@ -281,7 +281,7 @@ func (db *DB) GetBandwidthAllocations() (map[string][]*Agreement, error) {
|
|||||||
|
|
||||||
agreements := make(map[string][]*Agreement)
|
agreements := make(map[string][]*Agreement)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var agreement *Agreement
|
agreement := &Agreement{}
|
||||||
var satellite string
|
var satellite string
|
||||||
err := rows.Scan(&satellite, &agreement.Agreement, &agreement.Signature)
|
err := rows.Scan(&satellite, &agreement.Agreement, &agreement.Signature)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -136,10 +136,14 @@ func TestHappyPath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
bandwidthAllocation := func(total int64) []byte {
|
bandwidthAllocation := func(satelliteID string, total int64) []byte {
|
||||||
return serialize(t, &pb.RenterBandwidthAllocation_Data{
|
return serialize(t, &pb.RenterBandwidthAllocation_Data{
|
||||||
PayerAllocation: &pb.PayerBandwidthAllocation{},
|
PayerAllocation: &pb.PayerBandwidthAllocation{
|
||||||
Total: total,
|
Data: serialize(t, &pb.PayerBandwidthAllocation_Data{
|
||||||
|
SatelliteId: []byte(satelliteID),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
Total: total,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,19 +151,19 @@ func TestHappyPath(t *testing.T) {
|
|||||||
allocationTests := []*pb.RenterBandwidthAllocation{
|
allocationTests := []*pb.RenterBandwidthAllocation{
|
||||||
{
|
{
|
||||||
Signature: []byte("signed by test"),
|
Signature: []byte("signed by test"),
|
||||||
Data: bandwidthAllocation(0),
|
Data: bandwidthAllocation("AB", 0),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Signature: []byte("signed by sigma"),
|
Signature: []byte("signed by sigma"),
|
||||||
Data: bandwidthAllocation(10),
|
Data: bandwidthAllocation("AB", 10),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Signature: []byte("signed by sigma"),
|
Signature: []byte("signed by sigma"),
|
||||||
Data: bandwidthAllocation(98),
|
Data: bandwidthAllocation("AB", 98),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Signature: []byte("signed by test"),
|
Signature: []byte("signed by test"),
|
||||||
Data: bandwidthAllocation(3),
|
Data: bandwidthAllocation("AB", 3),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,6 +197,35 @@ func TestHappyPath(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Get all Bandwidth Allocations", func(t *testing.T) {
|
||||||
|
for P := 0; P < concurrency; P++ {
|
||||||
|
t.Run("#"+strconv.Itoa(P), func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
agreementGroups, err := db.GetBandwidthAllocations()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
found := false
|
||||||
|
for _, agreements := range agreementGroups {
|
||||||
|
for _, agreement := range agreements {
|
||||||
|
for _, test := range allocationTests {
|
||||||
|
if bytes.Equal(agreement.Agreement, test.Data) {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
t.Fatal("did not find added bandwidth allocation")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBandwidthUsage(t *testing.T) {
|
func TestBandwidthUsage(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user