test the isunsealed api

This commit is contained in:
Aarsh Shah 2021-07-30 13:14:47 +05:30
parent 8cd305338a
commit ab888c3a07

View File

@ -45,6 +45,8 @@ func TestLotusAccessorFetchUnsealedPiece(t *testing.T) {
name string
deals []abi.SectorNumber
fetchedData string
isUnsealed bool
expectErr bool
}{{
// Expect error if there is no deal info for piece CID
@ -56,11 +58,13 @@ func TestLotusAccessorFetchUnsealedPiece(t *testing.T) {
name: "prefer unsealed deal",
deals: []abi.SectorNumber{unsealedSectorID, sealedSectorID},
fetchedData: unsealedSectorData,
isUnsealed: true,
}, {
// Expect the API to unseal the data if there are no unsealed deals
name: "unseal if necessary",
deals: []abi.SectorNumber{sealedSectorID},
fetchedData: sealedSectorData,
isUnsealed: false,
}}
for _, tc := range testCases {
@ -95,6 +99,10 @@ func TestLotusAccessorFetchUnsealedPiece(t *testing.T) {
require.NoError(t, err)
require.Equal(t, tc.fetchedData, string(bz))
uns, err := api.IsUnsealed(ctx, cid1)
require.NoError(t, err)
require.Equal(t, tc.isUnsealed, uns)
})
}
}