diff --git a/test/spec/runners/bls.ex b/test/spec/runners/bls.ex index 38c974057..292e7e89a 100644 --- a/test/spec/runners/bls.ex +++ b/test/spec/runners/bls.ex @@ -137,14 +137,4 @@ defmodule BlsTestRunner do end end - # defp handle_case( - # "key_validate", - # %{pubkeys: pubkeys}, - # output - # ) do - # case Bls.key_validate(pubkeys) do - # {:ok, true} -> - # assert output - # end - # end end diff --git a/test/unit/bls_test.exs b/test/unit/bls_test.exs new file mode 100644 index 000000000..b4aecf732 --- /dev/null +++ b/test/unit/bls_test.exs @@ -0,0 +1,30 @@ +def BlsTest do + use ExUnit.Case + use Rustler, otp_app: :lambda_ethereum_consensus, crate: "bls_nif" + alias Bls.key_validate, as: key_validate + describe "validate_key" do + test "returns true for valid public key" do + valid_public_key = << + 0x8a, 0xfc, 0x8f, 0x13, 0x47, 0x90, 0x91, 0x4b, + 0x4a, 0x15, 0xd2, 0xfa, 0x73, 0xb0, 0x7c, 0xaf, + 0xd0, 0xd3, 0x08, 0x84, 0xfd, 0x80, 0xca, 0x22, + 0x0c, 0x8b, 0x95, 0x03, 0xf5, 0xf6, 0x9c, 0x33, + 0xdd, 0x27, 0x27, 0x5b, 0x12, 0x95, 0x43, 0xd2, + 0xf7, 0xf8, 0xf6, 0x35, 0xa8, 0x18, 0x67, 0xa0 + >> + assert key_validate(valid_public_key) == true + end + test "returns false for invalid public key" do + invalid_public_key = << + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + >> + assert key_validate(valid_public_key) == false + end + end + +end