Skip to content
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

Faker::Tezos: add block faker #1631

Merged
merged 2 commits into from Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/unreleased/blockchain/tezos.md
Expand Up @@ -9,5 +9,7 @@ Faker::Blockchain::Tezos.contract #=> "KT1MroqeP15nnitB4CnNfkqHYa2NErhPPLWF"

Faker::Blockchain::Tezos.operation #=> "onygWYXJX3xNstFLv9PcCrhQdCkENC795xwSinmTEc1jsDN4VDa"

Faker::Blockchain::Tezos.block #=> "BMbhs2rkY1dvAkAyRytvPsjFQ2RiPrBhYkxvWpY65dzkdSuw58a"

Faker::Blockchain::Tezos.signature #=> "edsigu165B7VFf3Dpw2QABVzEtCxJY2gsNBNcE3Ti7rRxtDUjqTFRpg67EdAQmY6YWPE5tKJDMnSTJDFu65gic8uLjbW2YwGvAZ"
```
15 changes: 10 additions & 5 deletions lib/faker/blockchain/tezos.rb
Expand Up @@ -8,12 +8,13 @@ class Blockchain
class Tezos < Base
class << self
PREFIXES = {
tz1: [6, 161, 159],
KT1: [2, 90, 121],
edpk: [13, 15, 37, 217],
tz1: [6, 161, 159],
KT1: [2, 90, 121],
edpk: [13, 15, 37, 217],
edsk: [13, 15, 58, 7],
edsig: [9, 245, 205, 134, 18],
o: [5, 116]
edsig: [9, 245, 205, 134, 18],
B: [1, 52],
o: [5, 116]
}.freeze

def account
Expand All @@ -28,6 +29,10 @@ def operation
encode_tz(:o, 32)
end

def block
encode_tz(:B, 32)
end

def signature
encode_tz(:edsig, 64)
end
Expand Down
4 changes: 4 additions & 0 deletions test/faker/blockchain/tezos.rb
Expand Up @@ -15,6 +15,10 @@ def test_operation
assert Faker::Blockchain::Tezos.operation.match(/^o[1-9A-Za-z][^OIl]{20,40}/)
end

def test_block
assert Faker::Tezos.block.match(/^B[1-9A-Za-z][^OIl]{20,40}/)
end

def test_signature
assert Faker::Blockchain::Tezos.signature.match(/^edsig[1-9A-Za-z][^OIl]{20,40}/)
end
Expand Down