-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupdate_blobber_test.go
88 lines (57 loc) · 3.37 KB
/
update_blobber_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package api_tests
import (
"testing"
"github.com/0chain/system_test/internal/api/util/test"
"github.com/0chain/system_test/internal/api/model"
"github.com/0chain/system_test/internal/api/util/client"
"github.com/stretchr/testify/require"
)
func TestUpdateBlobber(testSetup *testing.T) {
t := test.NewSystemTest(testSetup)
t.SetSmokeTests("Update blobber in allocation without correct delegated client, shouldn't work")
t.Parallel()
t.Run("update blobber version should work", func(t *test.SystemTest) {
wallet := createWallet(t)
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus)
allocation := apiClient.GetAllocation(t, allocationID, client.HttpOkStatus)
blobberID := getFirstUsedStorageNodeID(allocationBlobbers.Blobbers, allocation.Blobbers)
require.NotZero(t, blobberID)
blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus)
require.NotEqual(t, wallet.Id, blobber.StakePoolSettings.DelegateWallet)
blobber.StorageVersion = 1
apiClient.UpdateBlobber(t, wallet, blobber, client.TxUnsuccessfulStatus)
blobber = apiClient.GetBlobber(t, blobberID, client.HttpOkStatus)
require.NotEqual(t, wallet.Id, blobber.StakePoolSettings.DelegateWallet)
require.Equal(t, int64(1), blobber.StorageVersion)
})
t.Run("update blobber: degrade version should not work", func(t *test.SystemTest) {
wallet := createWallet(t)
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus)
allocation := apiClient.GetAllocation(t, allocationID, client.HttpOkStatus)
blobberID := getFirstUsedStorageNodeID(allocationBlobbers.Blobbers, allocation.Blobbers)
require.NotZero(t, blobberID)
blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus)
require.NotEqual(t, wallet.Id, blobber.StakePoolSettings.DelegateWallet)
blobber.StorageVersion = 0
apiClient.UpdateBlobber(t, wallet, blobber, client.TxUnsuccessfulStatus)
blobber = apiClient.GetBlobber(t, blobberID, client.HttpOkStatus)
require.NotEqual(t, wallet.Id, blobber.StakePoolSettings.DelegateWallet)
require.Equal(t, int64(1), blobber.StorageVersion)
})
t.Run("Update blobber in allocation without correct delegated client, shouldn't work", func(t *test.SystemTest) {
wallet := createWallet(t)
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus)
allocation := apiClient.GetAllocation(t, allocationID, client.HttpOkStatus)
blobberID := getFirstUsedStorageNodeID(allocationBlobbers.Blobbers, allocation.Blobbers)
require.NotZero(t, blobberID)
blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus)
require.NotEqual(t, wallet.Id, blobber.StakePoolSettings.DelegateWallet)
apiClient.UpdateBlobber(t, wallet, blobber, client.TxUnsuccessfulStatus)
})
}