-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to specify keypair and matching public key
- Loading branch information
Meta Head
committed
Jul 26, 2024
1 parent
d9f06dd
commit d0ad5de
Showing
3 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module NearApi | ||
VERSION = '0.2.2' | ||
VERSION = '0.2.3' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
require 'spec_helper' | ||
|
||
RSpec.describe NearApi::Key do | ||
describe '#initialize' do | ||
subject(:key) { described_class.new('test.near', key_pair: key_pair, public_key: public_key) } | ||
let(:key_pair) { 'ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw' } | ||
let(:public_key) { nil } | ||
|
||
it 'initialize without and error' do | ||
expect { key }.not_to raise_exception | ||
end | ||
|
||
context 'with public_key only' do | ||
let(:key_pair) { nil } | ||
let(:public_key) { 'ed25519:22skMptHjFWNyuEWY22ftn2AbLPSYpmYwGJRGwpNHbTV' } | ||
|
||
it 'initialize without and error' do | ||
expect { key }.not_to raise_exception | ||
end | ||
end | ||
|
||
context 'with keypair and matching public key' do | ||
let(:key_pair) { 'ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw' } | ||
let(:public_key) { 'ed25519:22skMptHjFWNyuEWY22ftn2AbLPSYpmYwGJRGwpNHbTV' } | ||
|
||
it 'initialize without and error' do | ||
expect { key }.not_to raise_exception | ||
end | ||
end | ||
|
||
context 'when keypair and public_key are missing' do | ||
let(:key_pair) { nil } | ||
let(:public_key) { nil } | ||
|
||
it 'raises an error' do | ||
expect { key }.to raise_exception ArgumentError, 'please specify key_pair or public_key' | ||
end | ||
end | ||
|
||
context 'when public_key does not match keypair' do | ||
let(:key_pair) { 'ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw' } | ||
let(:public_key) { 'ed25519:BEU6Smwd5nADfTknr4r5E751Me6L4fNL7obQHYbh4FCL' } | ||
|
||
it 'raises an error' do | ||
expect { key }.to raise_exception ArgumentError, 'public_key does not match keypair' | ||
end | ||
end | ||
end | ||
end | ||
|