diff --git a/go.mod b/go.mod index 19475c9..e9bda9f 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.23.2 require ( go.etcd.io/bbolt v1.3.11 - go.sia.tech/core v0.8.0 + go.sia.tech/core v0.8.1-0.20241217152409-7950a7ca324b go.sia.tech/mux v1.3.0 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.31.0 diff --git a/go.sum b/go.sum index 25118a3..bf2c74b 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= -go.sia.tech/core v0.8.0 h1:J6vZQlVhpj4bTVeuC2GKkfkGEs8jf0j651Kl1wwOxjg= -go.sia.tech/core v0.8.0/go.mod h1:Wj1qzvpMM2rqEQjwWJEbCBbe9VWX/mSJUu2Y2ABl1QA= +go.sia.tech/core v0.8.1-0.20241217152409-7950a7ca324b h1:VRkb6OOX1KawLQwuqOEHLcjha8gxVX0tAyu2Dyoq8Ek= +go.sia.tech/core v0.8.1-0.20241217152409-7950a7ca324b/go.mod h1:Wj1qzvpMM2rqEQjwWJEbCBbe9VWX/mSJUu2Y2ABl1QA= go.sia.tech/mux v1.3.0 h1:hgR34IEkqvfBKUJkAzGi31OADeW2y7D6Bmy/Jcbop9c= go.sia.tech/mux v1.3.0/go.mod h1:I46++RD4beqA3cW9Xm9SwXbezwPqLvHhVs9HLpDtt58= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= diff --git a/rhp/v4/rpc_test.go b/rhp/v4/rpc_test.go index 38a52d5..3911dd1 100644 --- a/rhp/v4/rpc_test.go +++ b/rhp/v4/rpc_test.go @@ -392,11 +392,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) @@ -550,11 +546,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.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) @@ -753,13 +745,7 @@ func TestAccounts(t *testing.T) { cs := cm.TipState() // test operations against unknown account - 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()) _, err = rhp4.RPCVerifySector(context.Background(), transport, settings.Prices, token, types.Hash256{1}) if err == nil || !strings.Contains(err.Error(), proto4.ErrNotEnoughFunds.Error()) { t.Fatal(err) @@ -886,14 +872,7 @@ func TestReadWriteSector(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()) data := frand.Bytes(1024) // store the sector @@ -1005,12 +984,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) @@ -1121,14 +1095,7 @@ func TestVerifySector(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()) data := frand.Bytes(1024) // store the sector @@ -1212,13 +1179,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 { @@ -1333,13 +1294,7 @@ func TestRPCSectorRoots(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, 0, 50) @@ -1441,12 +1396,7 @@ func BenchmarkWrite(b *testing.B) { b.Fatal(err) } 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++ { @@ -1529,12 +1479,7 @@ func BenchmarkRead(b *testing.B) { b.Fatal(err) } 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) @@ -1629,12 +1574,7 @@ func BenchmarkContractUpload(b *testing.B) { b.Fatal(err) } 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)