Skip to content

hand out bumps to the cosmwasm crew #644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions internal/api/memory_test_no_cgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package api

/*
#include "bindings.h"
*/
import "C"

import (
"testing"
"unsafe"

"github.com/stretchr/testify/require"
)

func TestCopyDestroyUnmanagedVectorNoCgo(t *testing.T) {
{
// ptr, cap and len broken. Do not access those values when is_none is true
base := unsafe.Pointer(&struct{ x byte }{}) //nolint:gosec
invalid_ptr := unsafe.Add(base, 42)
uv := constructUnmanagedVector(true, cu8_ptr(invalid_ptr), 0xBB, 0xAA)
copy := copyAndDestroyUnmanagedVector(uv)
require.Nil(t, copy)
}
{
// Capacity is 0, so no allocation happened. Do not access the pointer.
base := unsafe.Pointer(&struct{ x byte }{}) //nolint:gosec
invalid_ptr := unsafe.Add(base, 42)
uv := constructUnmanagedVector(false, cu8_ptr(invalid_ptr), 0, 0)
copy := copyAndDestroyUnmanagedVector(uv)
require.Equal(t, []byte{}, copy)
}
}
Loading