Skip to content

Commit

Permalink
Faker::Tezos: add block faker (faker-ruby#1631)
Browse files Browse the repository at this point in the history
* Faker::Tezos: add block faker

* Faker::Blockhain::Tezos: add documentation for #block
  • Loading branch information
akettal authored and michebble committed Feb 16, 2020
1 parent bc5cab0 commit 19d6e5e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
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

0 comments on commit 19d6e5e

Please sign in to comment.