-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathremove_blobber_test.go
48 lines (33 loc) · 1.62 KB
/
remove_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
package api_tests
import (
"testing"
"time"
"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/0chain/system_test/internal/api/util/wait"
"github.com/stretchr/testify/require"
)
func TestRemoveBlobber(testSetup *testing.T) {
t := test.NewSystemTest(testSetup)
t.SetSmokeTests("Remove blobber in allocation, shouldn't work")
t.Parallel()
t.Run("Remove blobber in allocation, 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)
numberOfBlobbersBefore := len(allocation.Blobbers)
oldBlobberID := getFirstUsedStorageNodeID(allocationBlobbers.Blobbers, allocation.Blobbers)
require.NotZero(t, oldBlobberID, "Old blobber ID contains zero value")
apiClient.UpdateAllocationBlobbers(t, wallet, "", oldBlobberID, allocationID, client.TxUnsuccessfulStatus)
var numberOfBlobbersAfter int
wait.PoolImmediately(t, time.Second*30, func() bool {
allocation = apiClient.GetAllocation(t, allocationID, client.HttpOkStatus)
numberOfBlobbersAfter = len(allocation.Blobbers)
return numberOfBlobbersAfter == numberOfBlobbersBefore
})
require.Equal(t, numberOfBlobbersAfter, numberOfBlobbersBefore)
})
}