diff --git a/array_test.go b/array_test.go index 6aefe1ed..8ce86fc8 100644 --- a/array_test.go +++ b/array_test.go @@ -161,7 +161,7 @@ func TestArrayAppendAndGet(t *testing.T) { var indexOutOfBoundsError *IndexOutOfBoundsError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &indexOutOfBoundsError) - require.ErrorAs(t, userError.Unwrap(), &indexOutOfBoundsError) + require.ErrorAs(t, userError, &indexOutOfBoundsError) verifyArray(t, storage, typeInfo, address, array, values, false) } @@ -327,7 +327,7 @@ func TestArraySetAndGet(t *testing.T) { var indexOutOfBoundsError *IndexOutOfBoundsError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &indexOutOfBoundsError) - require.ErrorAs(t, userError.Unwrap(), &indexOutOfBoundsError) + require.ErrorAs(t, userError, &indexOutOfBoundsError) verifyArray(t, storage, typeInfo, address, array, values, false) }) @@ -444,7 +444,7 @@ func TestArrayInsertAndGet(t *testing.T) { var indexOutOfBoundsError *IndexOutOfBoundsError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &indexOutOfBoundsError) - require.ErrorAs(t, userError.Unwrap(), &indexOutOfBoundsError) + require.ErrorAs(t, userError, &indexOutOfBoundsError) verifyArray(t, storage, typeInfo, address, array, values, false) }) @@ -630,7 +630,7 @@ func TestArrayRemove(t *testing.T) { var indexOutOfBounds *IndexOutOfBoundsError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &indexOutOfBounds) - require.ErrorAs(t, userError.Unwrap(), &indexOutOfBounds) + require.ErrorAs(t, userError, &indexOutOfBounds) verifyArray(t, storage, typeInfo, address, array, values, false) }) @@ -870,7 +870,7 @@ func testArrayIterateRange(t *testing.T, storage *PersistentSlabStorage, array * var userError *UserError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &sliceOutOfBoundsError) - require.ErrorAs(t, userError.Unwrap(), &sliceOutOfBoundsError) + require.ErrorAs(t, userError, &sliceOutOfBoundsError) require.Equal(t, uint64(0), i) // If endIndex > count, IterateRange returns SliceOutOfBoundsError @@ -881,7 +881,7 @@ func testArrayIterateRange(t *testing.T, storage *PersistentSlabStorage, array * require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &sliceOutOfBoundsError) - require.ErrorAs(t, userError.Unwrap(), &sliceOutOfBoundsError) + require.ErrorAs(t, userError, &sliceOutOfBoundsError) require.Equal(t, uint64(0), i) // If startIndex > endIndex, IterateRange returns InvalidSliceIndexError @@ -893,7 +893,7 @@ func testArrayIterateRange(t *testing.T, storage *PersistentSlabStorage, array * require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &invalidSliceIndexError) - require.ErrorAs(t, userError.Unwrap(), &invalidSliceIndexError) + require.ErrorAs(t, userError, &invalidSliceIndexError) require.Equal(t, uint64(0), i) } @@ -1811,7 +1811,7 @@ func TestEmptyArray(t *testing.T) { var indexOutOfBoundsError *IndexOutOfBoundsError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &indexOutOfBoundsError) - require.ErrorAs(t, userError.Unwrap(), &indexOutOfBoundsError) + require.ErrorAs(t, userError, &indexOutOfBoundsError) require.Nil(t, s) }) @@ -1822,7 +1822,7 @@ func TestEmptyArray(t *testing.T) { var indexOutOfBoundsError *IndexOutOfBoundsError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &indexOutOfBoundsError) - require.ErrorAs(t, userError.Unwrap(), &indexOutOfBoundsError) + require.ErrorAs(t, userError, &indexOutOfBoundsError) require.Nil(t, s) }) @@ -1833,7 +1833,7 @@ func TestEmptyArray(t *testing.T) { var indexOutOfBoundsError *IndexOutOfBoundsError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &indexOutOfBoundsError) - require.ErrorAs(t, userError.Unwrap(), &indexOutOfBoundsError) + require.ErrorAs(t, userError, &indexOutOfBoundsError) }) t.Run("remove", func(t *testing.T) { @@ -1843,7 +1843,7 @@ func TestEmptyArray(t *testing.T) { var indexOutOfBoundsError *IndexOutOfBoundsError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &indexOutOfBoundsError) - require.ErrorAs(t, userError.Unwrap(), &indexOutOfBoundsError) + require.ErrorAs(t, userError, &indexOutOfBoundsError) require.Nil(t, s) }) @@ -1986,7 +1986,7 @@ func TestArrayStoredValue(t *testing.T) { var notValueError *NotValueError require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, ¬ValueError) - require.ErrorAs(t, fatalError.Unwrap(), ¬ValueError) + require.ErrorAs(t, fatalError, ¬ValueError) require.Nil(t, value) } } diff --git a/map_test.go b/map_test.go index da73e088..3b3ced33 100644 --- a/map_test.go +++ b/map_test.go @@ -512,7 +512,7 @@ func TestMapGetKeyNotFound(t *testing.T) { var keyNotFoundError *KeyNotFoundError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &keyNotFoundError) - require.ErrorAs(t, userError.Unwrap(), &keyNotFoundError) + require.ErrorAs(t, userError, &keyNotFoundError) verifyMap(t, storage, typeInfo, address, m, keyValues, nil, false) }) @@ -555,7 +555,7 @@ func TestMapGetKeyNotFound(t *testing.T) { var keyNotFoundError *KeyNotFoundError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &keyNotFoundError) - require.ErrorAs(t, userError.Unwrap(), &keyNotFoundError) + require.ErrorAs(t, userError, &keyNotFoundError) verifyMap(t, storage, typeInfo, address, m, keyValues, nil, false) }) @@ -598,7 +598,7 @@ func TestMapGetKeyNotFound(t *testing.T) { var keyNotFoundError *KeyNotFoundError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &keyNotFoundError) - require.ErrorAs(t, userError.Unwrap(), &keyNotFoundError) + require.ErrorAs(t, userError, &keyNotFoundError) verifyMap(t, storage, typeInfo, address, m, keyValues, nil, false) }) @@ -708,7 +708,7 @@ func testMapRemoveElement(t *testing.T, m *OrderedMap, k Value, expectedV Value) var keyNotFoundError *KeyNotFoundError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &keyNotFoundError) - require.ErrorAs(t, userError.Unwrap(), &keyNotFoundError) + require.ErrorAs(t, userError, &keyNotFoundError) require.Nil(t, removedKeyStorable) require.Nil(t, removedValueStorable) } @@ -998,7 +998,7 @@ func TestMapRemove(t *testing.T) { var keyNotFoundError *KeyNotFoundError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &keyNotFoundError) - require.ErrorAs(t, userError.Unwrap(), &keyNotFoundError) + require.ErrorAs(t, userError, &keyNotFoundError) verifyMap(t, storage, typeInfo, address, m, keyValues, nil, false) }) @@ -1042,7 +1042,7 @@ func TestMapRemove(t *testing.T) { var keyNotFoundError *KeyNotFoundError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &keyNotFoundError) - require.ErrorAs(t, userError.Unwrap(), &keyNotFoundError) + require.ErrorAs(t, userError, &keyNotFoundError) verifyMap(t, storage, typeInfo, address, m, keyValues, nil, false) }) @@ -2816,7 +2816,7 @@ func TestMapStoredValue(t *testing.T) { var notValueError *NotValueError require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, ¬ValueError) - require.ErrorAs(t, fatalError.Unwrap(), ¬ValueError) + require.ErrorAs(t, fatalError, ¬ValueError) require.Nil(t, value) } } @@ -3043,7 +3043,7 @@ func TestEmptyMap(t *testing.T) { var keyNotFoundError *KeyNotFoundError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &keyNotFoundError) - require.ErrorAs(t, userError.Unwrap(), &keyNotFoundError) + require.ErrorAs(t, userError, &keyNotFoundError) require.Nil(t, s) }) @@ -3054,7 +3054,7 @@ func TestEmptyMap(t *testing.T) { var keyNotFoundError *KeyNotFoundError require.ErrorAs(t, err, &userError) require.ErrorAs(t, err, &keyNotFoundError) - require.ErrorAs(t, userError.Unwrap(), &keyNotFoundError) + require.ErrorAs(t, userError, &keyNotFoundError) require.Nil(t, existingKey) require.Nil(t, existingValue) }) @@ -3982,7 +3982,7 @@ func TestMaxCollisionLimitPerDigest(t *testing.T) { var collisionLimitError *CollisionLimitError require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &collisionLimitError) - require.ErrorAs(t, fatalError.Unwrap(), &collisionLimitError) + require.ErrorAs(t, fatalError, &collisionLimitError) require.Nil(t, existingStorable) } @@ -4056,7 +4056,7 @@ func TestMaxCollisionLimitPerDigest(t *testing.T) { var collisionLimitError *CollisionLimitError require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &collisionLimitError) - require.ErrorAs(t, fatalError.Unwrap(), &collisionLimitError) + require.ErrorAs(t, fatalError, &collisionLimitError) require.Nil(t, existingStorable) } diff --git a/slab_test.go b/slab_test.go index 84631f8b..433f2e81 100644 --- a/slab_test.go +++ b/slab_test.go @@ -60,21 +60,21 @@ func TestIsRootOfAnObject(t *testing.T) { require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &decodingError) - require.ErrorAs(t, fatalError.Unwrap(), &decodingError) + require.ErrorAs(t, fatalError, &decodingError) isRoot, err = IsRootOfAnObject([]byte{}) require.False(t, isRoot) require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &decodingError) - require.ErrorAs(t, fatalError.Unwrap(), &decodingError) + require.ErrorAs(t, fatalError, &decodingError) isRoot, err = IsRootOfAnObject([]byte{0x00}) require.False(t, isRoot) require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &decodingError) - require.ErrorAs(t, fatalError.Unwrap(), &decodingError) + require.ErrorAs(t, fatalError, &decodingError) }) } @@ -114,21 +114,21 @@ func TestHasPointers(t *testing.T) { require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &decodingError) - require.ErrorAs(t, fatalError.Unwrap(), &decodingError) + require.ErrorAs(t, fatalError, &decodingError) hasPointers, err = HasPointers([]byte{}) require.False(t, hasPointers) require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &decodingError) - require.ErrorAs(t, fatalError.Unwrap(), &decodingError) + require.ErrorAs(t, fatalError, &decodingError) hasPointers, err = HasPointers([]byte{0x00}) require.False(t, hasPointers) require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &decodingError) - require.ErrorAs(t, fatalError.Unwrap(), &decodingError) + require.ErrorAs(t, fatalError, &decodingError) }) } @@ -168,20 +168,20 @@ func TestHasSizeLimit(t *testing.T) { require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &decodingError) - require.ErrorAs(t, fatalError.Unwrap(), &decodingError) + require.ErrorAs(t, fatalError, &decodingError) hasSizeLimit, err = HasSizeLimit([]byte{}) require.False(t, hasSizeLimit) require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &decodingError) - require.ErrorAs(t, fatalError.Unwrap(), &decodingError) + require.ErrorAs(t, fatalError, &decodingError) hasSizeLimit, err = HasSizeLimit([]byte{0x00}) require.False(t, hasSizeLimit) require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &decodingError) - require.ErrorAs(t, fatalError.Unwrap(), &decodingError) + require.ErrorAs(t, fatalError, &decodingError) }) } diff --git a/storage_test.go b/storage_test.go index bf299f5d..d91cc557 100644 --- a/storage_test.go +++ b/storage_test.go @@ -56,14 +56,14 @@ func TestNewStorageIDFromRawBytes(t *testing.T) { require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &storageIDError) - require.ErrorAs(t, fatalError.Unwrap(), &storageIDError) + require.ErrorAs(t, fatalError, &storageIDError) id, err = NewStorageIDFromRawBytes([]byte{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2}) require.Equal(t, StorageIDUndefined, id) require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &storageIDError) - require.ErrorAs(t, fatalError.Unwrap(), &storageIDError) + require.ErrorAs(t, fatalError, &storageIDError) }) t.Run("data length == storage id size", func(t *testing.T) { @@ -98,7 +98,7 @@ func TestStorageIDToRawBytes(t *testing.T) { require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &storageIDError) - require.ErrorAs(t, fatalError.Unwrap(), &storageIDError) + require.ErrorAs(t, fatalError, &storageIDError) }) t.Run("buffer too short", func(t *testing.T) { @@ -111,7 +111,7 @@ func TestStorageIDToRawBytes(t *testing.T) { require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &storageIDError) - require.ErrorAs(t, fatalError.Unwrap(), &storageIDError) + require.ErrorAs(t, fatalError, &storageIDError) }) t.Run("undefined", func(t *testing.T) { @@ -190,7 +190,7 @@ func TestStorageIDValid(t *testing.T) { require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &storageIDError) - require.ErrorAs(t, fatalError.Unwrap(), &storageIDError) + require.ErrorAs(t, fatalError, &storageIDError) }) t.Run("temp index", func(t *testing.T) { id := StorageID{Address: Address{1}, Index: StorageIndexUndefined} @@ -201,7 +201,7 @@ func TestStorageIDValid(t *testing.T) { require.Equal(t, 1, errorCategorizationCount(err)) require.ErrorAs(t, err, &fatalError) require.ErrorAs(t, err, &storageIDError) - require.ErrorAs(t, fatalError.Unwrap(), &storageIDError) + require.ErrorAs(t, fatalError, &storageIDError) }) t.Run("temp address", func(t *testing.T) { id := StorageID{Address: AddressUndefined, Index: StorageIndex{1}}