Skip to content

Commit 8b63ae6

Browse files
author
dndll
committed
test: remove unneeded clear since we take the err already
1 parent 29feed3 commit 8b63ae6

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

crates/da-rpc-sys/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ pub extern "C" fn get_error() -> *mut c_char {
5555
}
5656
}
5757

58+
/// # Safety
59+
/// We check if the pointers are null
60+
/// This is only used in a test
61+
#[no_mangle]
62+
pub unsafe extern "C" fn set_error(err: *const c_char) {
63+
null_pointer_check!(err);
64+
let msg = FfiStr::from_raw(err).into_string();
65+
ffi_helpers::error_handling::update_last_error(anyhow::anyhow!(msg));
66+
}
67+
5868
#[no_mangle]
5969
pub extern "C" fn clear_error() {
6070
ffi_helpers::error_handling::clear_last_error();

gopkg/da-rpc/near.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,6 @@ func GetDAError() (err error) {
238238
if errData != nil {
239239
defer C.free(unsafe.Pointer(errData))
240240

241-
C.clear_error()
242-
243241
errStr := C.GoString(errData)
244242
return fmt.Errorf("NEAR DA client %s", errStr)
245243
} else {

gopkg/da-rpc/near_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ func TestTo32Bytes(t *testing.T) {
162162

163163
func TestGetDAError(t *testing.T) {
164164
// Test error case
165-
// TODO: Mock the C.get_error function to return an error
166165
near.TestSetError("test error")
167166
err := near.GetDAError()
168167
assert.Error(t, err)

0 commit comments

Comments
 (0)