Skip to content

Commit

Permalink
e2e: use token helper in rhp4 integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Dec 19, 2024
1 parent 048fcb0 commit ccea311
Showing 1 changed file with 11 additions and 67 deletions.
78 changes: 11 additions & 67 deletions internal/integration/rhp/v4/rhp4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,7 @@ func TestRPCRefresh(t *testing.T) {
revision.Revision = fundResult.Revision

// upload data
at := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(5 * time.Minute),
}
at.Signature = renterKey.SignHash(at.SigHash())
at := account.Token(renterKey, hostKey.PublicKey())
wRes, err := rhp4.RPCWriteSector(context.Background(), transport, settings.Prices, at, bytes.NewReader(bytes.Repeat([]byte{1}, proto4.LeafSize)), proto4.LeafSize)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -356,10 +352,7 @@ func TestRPCRenew(t *testing.T) {
revision.Revision = fundResult.Revision

// upload data
at := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(5 * time.Minute),
}
at := account.Token(renterKey, hostKey.PublicKey())
at.Signature = renterKey.SignHash(at.SigHash())
wRes, err := rhp4.RPCWriteSector(context.Background(), transport, settings.Prices, at, bytes.NewReader(bytes.Repeat([]byte{1}, proto4.LeafSize)), proto4.LeafSize)
if err != nil {
Expand Down Expand Up @@ -642,13 +635,7 @@ func TestReadWriteSector(t *testing.T) {
}
revision.Revision = fundResult.Revision

token := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(time.Hour),
}
tokenSigHash := token.SigHash()
token.Signature = renterKey.SignHash(tokenSigHash)

token := account.Token(renterKey, hostKey.PublicKey())
data := frand.Bytes(1024)

// store the sector
Expand Down Expand Up @@ -749,13 +736,7 @@ func TestAppendSectors(t *testing.T) {
revision.Revision = fundResult.Revision
assertLastRevision(t)

token := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(time.Hour),
}
tokenSigHash := token.SigHash()
token.Signature = renterKey.SignHash(tokenSigHash)

token := account.Token(renterKey, hostKey.PublicKey())
// store random sectors
roots := make([]types.Hash256, 0, 10)
for i := 0; i < 10; i++ {
Expand Down Expand Up @@ -854,13 +835,7 @@ func TestVerifySector(t *testing.T) {
}
revision.Revision = fundResult.Revision

token := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(time.Hour),
}
tokenSigHash := token.SigHash()
token.Signature = renterKey.SignHash(tokenSigHash)

token := account.Token(renterKey, hostKey.PublicKey())
data := frand.Bytes(1024)

// store the sector
Expand Down Expand Up @@ -932,14 +907,7 @@ func TestRPCFreeSectors(t *testing.T) {
t.Fatal(err)
}
revision.Revision = fundResult.Revision

token := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(time.Hour),
}
tokenSigHash := token.SigHash()
token.Signature = renterKey.SignHash(tokenSigHash)

token := account.Token(renterKey, hostKey.PublicKey())
roots := make([]types.Hash256, 10)
for i := range roots {
// store random sectors on the host
Expand Down Expand Up @@ -1042,13 +1010,7 @@ func TestRPCSectorRoots(t *testing.T) {
}
revision.Revision = fundResult.Revision

token := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(time.Hour),
}
tokenSigHash := token.SigHash()
token.Signature = renterKey.SignHash(tokenSigHash)

token := account.Token(renterKey, hostKey.PublicKey())
roots := make([]types.Hash256, 0, 50)

checkRoots := func(t *testing.T, expected []types.Hash256) {
Expand Down Expand Up @@ -1138,13 +1100,7 @@ func TestPrune(t *testing.T) {
}
revision.Revision = fundResult.Revision

token := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(time.Hour),
}
tokenSigHash := token.SigHash()
token.Signature = renterKey.SignHash(tokenSigHash)

token := account.Token(renterKey, hostKey.PublicKey())
tempExpirationHeight := cm.Tip().Height + proto4.TempSectorDuration
roots := make([]types.Hash256, 10)
for i := 0; i < len(roots); i++ {
Expand Down Expand Up @@ -1255,11 +1211,7 @@ func BenchmarkWrite(b *testing.B) {
}
revision.Revision = fundResult.Revision

token := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(time.Hour),
}
token.Signature = renterKey.SignHash(token.SigHash())
token := account.Token(renterKey, hostKey.PublicKey())

var sectors [][proto4.SectorSize]byte
for i := 0; i < b.N; i++ {
Expand Down Expand Up @@ -1331,11 +1283,7 @@ func BenchmarkRead(b *testing.B) {
}
revision.Revision = fundResult.Revision

token := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(time.Hour),
}
token.Signature = renterKey.SignHash(token.SigHash())
token := account.Token(renterKey, hostKey.PublicKey())

var sectors [][proto4.SectorSize]byte
roots := make([]types.Hash256, 0, b.N)
Expand Down Expand Up @@ -1419,11 +1367,7 @@ func BenchmarkContractUpload(b *testing.B) {
}
revision.Revision = fundResult.Revision

token := proto4.AccountToken{
Account: account,
ValidUntil: time.Now().Add(time.Hour),
}
token.Signature = renterKey.SignHash(token.SigHash())
token := account.Token(renterKey, hostKey.PublicKey())

var sectors [][proto4.SectorSize]byte
roots := make([]types.Hash256, 0, b.N)
Expand Down

0 comments on commit ccea311

Please sign in to comment.