-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from keep-starknet-strange/mk/test_data
[feat] Script to generate test data, with a bit refactoring
- Loading branch information
Showing
12 changed files
with
276 additions
and
194 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 was deleted.
Oops, something went wrong.
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,72 @@ | ||
def txin_coinbase: | ||
"TxIn { | ||
script: from_base16(\"\(.coinbase)\"), | ||
sequence: \(.sequence), | ||
previous_output: OutPoint { | ||
txid: 0_u256, | ||
vout: 0xffffffff_u32, | ||
txo_index: 0, // TODO: implement | ||
}, | ||
}" | ||
; | ||
|
||
def txin_regular: | ||
"TxIn { | ||
script: from_base16(\"\(.scriptSig.hex)\"), | ||
sequence: \(.sequence), | ||
previous_output: OutPoint { | ||
txid: 0x\(.txid), | ||
vout: \(.vout), | ||
txo_index: 0, // TODO: implement | ||
}, | ||
}" | ||
; | ||
|
||
def txin: | ||
if .coinbase then | ||
txin_coinbase | ||
else | ||
txin_regular | ||
end | ||
; | ||
|
||
def txout: | ||
"TxOut { | ||
value: \(.value*100000000)_u64, | ||
pk_script: from_base16(\"\(.scriptPubKey.hex)\"), | ||
}" | ||
; | ||
|
||
def tx: | ||
"Transaction { | ||
version: \(.version), | ||
is_segwit: false, | ||
inputs: array![\(.vin | map(txin) | join(",\n"))].span(), | ||
outputs: array![\(.vout | map(txout) | join(",\n"))].span(), | ||
lock_time: \(.locktime) | ||
}" | ||
; | ||
|
||
|
||
def block: | ||
"Block { | ||
header : Header { | ||
version: \(.version)_u32, | ||
time: \(.time)_u32, | ||
nonce: \(.nonce)_u32 | ||
}, | ||
txs: array![\(.tx | map(tx) | join(",\n"))].span() | ||
};" | ||
; | ||
|
||
def fixture: | ||
"use super::state::{Block, Header, Transaction, OutPoint, TxIn, TxOut}; | ||
pub fn block_\(.height)() -> Block { | ||
// block hash: \(.hash) | ||
\( . | block ) | ||
}" | ||
; | ||
|
||
.result | fixture | ||
|
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,20 @@ | ||
#! /usr/bin/env bash | ||
set -e; | ||
set -o pipefail; | ||
|
||
HEIGHT=$(curl -s --user $USERPWD -s -d '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockheader", "params": ["'${1}'"] }' -H 'content-type: text/plain;' $BITCOIN_RPC | jq -r '.result.height') | ||
|
||
curl \ | ||
-s \ | ||
--user $USERPWD \ | ||
-d '{ | ||
"jsonrpc": "1.0", | ||
"id": "curltest", | ||
"method": "getblock", | ||
"params": ["'${1}'", 2] | ||
}' \ | ||
-H 'content-type: text/plain;' $BITCOIN_RPC \ | ||
| jq -r -f scripts/data/block_filter.jq > tests/blocks/block_${HEIGHT}.cairo | ||
|
||
validate_target, validate_timestamp, validate_proof_of_work, compute_block_reward, | ||
compute_total_work, |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.