Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guha-rahul committed Apr 22, 2024
1 parent 6ac413c commit 61e8fb3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
10 changes: 0 additions & 10 deletions test/spec/runners/bls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 30 additions & 0 deletions test/unit/bls_test.exs
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 61e8fb3

Please sign in to comment.