From ccea311ecc193643f18066cfef92cb8af9a22b45 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 19 Dec 2024 13:46:58 -0800 Subject: [PATCH] e2e: use token helper in rhp4 integration tests --- internal/integration/rhp/v4/rhp4_test.go | 78 ++++-------------------- 1 file changed, 11 insertions(+), 67 deletions(-) diff --git a/internal/integration/rhp/v4/rhp4_test.go b/internal/integration/rhp/v4/rhp4_test.go index 7ad5f5fe..7b76eba6 100644 --- a/internal/integration/rhp/v4/rhp4_test.go +++ b/internal/integration/rhp/v4/rhp4_test.go @@ -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) @@ -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 { @@ -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 @@ -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++ { @@ -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 @@ -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 @@ -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) { @@ -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++ { @@ -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++ { @@ -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) @@ -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)