Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Feb 20, 2024
1 parent 0193d1e commit d0d4ce0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
10 changes: 9 additions & 1 deletion adapters/sn2core/sn2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func AdaptBlock(response *starknet.Block, sig *starknet.Signature) (*core.Block,
}
}

var l1DAMode core.L1DAMode
switch response.L1DAMode {
case starknet.CallData:
l1DAMode = core.L1DAModeCALLDATA

Check warning on line 61 in adapters/sn2core/sn2core.go

View check run for this annotation

Codecov / codecov/patch

adapters/sn2core/sn2core.go#L60-L61

Added lines #L60 - L61 were not covered by tests
case starknet.Blob:
l1DAMode = core.L1DAModeBLOB
}

return &core.Block{
Header: &core.Header{
Hash: response.Hash,
Expand All @@ -69,7 +77,7 @@ func AdaptBlock(response *starknet.Block, sig *starknet.Signature) (*core.Block,
EventsBloom: core.EventsBloom(receipts),
GasPrice: response.GasPriceETH(),
GasPriceSTRK: response.GasPriceSTRK,
L1DAMode: core.L1DAMode(response.L1DAMode),
L1DAMode: l1DAMode,
L1DataGasPrice: L1DataGasPrice,
L1GasPrice: L1GasPrice,
Signatures: sigs,
Expand Down
26 changes: 14 additions & 12 deletions adapters/sn2core/sn2core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ func TestAdaptBlock(t *testing.T) {
sig *starknet.Signature
gasPriceWEI *felt.Felt
gasPriceSTRK *felt.Felt
daGasPriceWEI *felt.Felt
daGasPriceFRI *felt.Felt
l1GasPriceWEI *felt.Felt
l1GasPriceFRI *felt.Felt
l1DAGasPriceWEI *felt.Felt
l1DAGasPriceFRI *felt.Felt
}{
{
number: 147,
Expand Down Expand Up @@ -65,14 +67,14 @@ func TestAdaptBlock(t *testing.T) {
protocolVersion: "0.13.1",
sig: &starknet.Signature{
Signature: []*felt.Felt{
utils.HexToFelt(t, "0x71a9b2cd8a8a6a4ca284dcddcdefc6c4fd20b92c1b201bd9836e4ce376fad16"),
utils.HexToFelt(t, "0x6bef4745194c9447fdc8dd3aec4fc738ab0a560b0d2c7bf62fbf58aef3abfc5"),
utils.HexToFelt(t, "0x7685fbcd4bacae7554ad17c6962221143911d894d7b8794d29234623f392562"),
utils.HexToFelt(t, "0x343e605de3957e664746ba8ef82f2b0f9d53cda3d75dcb078290b8edd010165"),
},
},
gasPriceWEI: utils.HexToFelt(t, "0x3b9aca08"),
gasPriceSTRK: utils.HexToFelt(t, "0x2540be400"),
daGasPriceWEI: utils.HexToFelt(t, "0x5265a14ef"),
daGasPriceFRI: utils.HexToFelt(t, "0x3c0c00c87"),
l1GasPriceWEI: utils.HexToFelt(t, "0x3b9aca08"),
l1GasPriceFRI: utils.HexToFelt(t, "0x2540be400"),
l1DAGasPriceWEI: utils.HexToFelt(t, "0x5265a14ef"),
l1DAGasPriceFRI: utils.HexToFelt(t, "0x3c0c00c87"),
},
}

Expand Down Expand Up @@ -119,11 +121,11 @@ func TestAdaptBlock(t *testing.T) {
assert.Equal(t, test.gasPriceSTRK, block.GasPriceSTRK)
assert.Equal(t, test.gasPriceWEI, block.GasPrice)

if test.daGasPriceFRI != nil {
assert.Equal(t, test.daGasPriceFRI, block.L1DataGasPrice.PriceInFri)
if test.l1DAGasPriceFRI != nil {
assert.Equal(t, test.l1DAGasPriceFRI, block.L1DataGasPrice.PriceInFri)
}
if test.daGasPriceFRI != nil {
assert.Equal(t, test.daGasPriceWEI, block.L1DataGasPrice.PriceInWei)
if test.l1DAGasPriceFRI != nil {
assert.Equal(t, test.l1DAGasPriceWEI, block.L1DataGasPrice.PriceInWei)
}
})
}
Expand Down
1 change: 1 addition & 0 deletions clients/feeder/testdata/integration/block/330363.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"block_hash": "0x8ab8117e952f95efd96de0bc66dc6f13fe68dfda14b95fe1972759dee283a8", "parent_block_hash": "0x2ef5b8b01ad9345f2b6be196005034baf42362c7406a89d8788b5969efaea1", "block_number": 330363, "state_root": "0x4406dc46518501c7530a13236d5620c8edbc53771c3b9080c148788ad76fd0c", "transaction_commitment": "0x13367121d0b7e34a9b10c8a5a1c269811cd9afc3ce680c88888f1a22d2f017a", "event_commitment": "0x1090dd2ab2aa22bd5fc5a59d3b1394d54461bb2a80156c4b2c2622d2c474ca2", "status": "ACCEPTED_ON_L1", "l1_da_mode": "BLOB", "l1_gas_price": {"price_in_wei": "0x3b9aca0a", "price_in_fri": "0x2b6fdb70"}, "l1_data_gas_price": {"price_in_wei": "0x5265a14ef", "price_in_fri": "0x3c0c00c87"}, "transactions": [{"transaction_hash": "0x1ffcecfdae93215db398482d3e91e065816bdeda116ef8d3e68f2f6c01a0e22", "version": "0x3", "signature": ["0x4de1bca2906135e43869ae416d6e5410660c2d1412678a743d3ab5f66bf78b0", "0x5b2f18362a175878089b2f69b2953e3427bb9135fc64d6c50f7f3efe4e5d6fb"], "nonce": "0xd0e", "nonce_data_availability_mode": 0, "fee_data_availability_mode": 0, "resource_bounds": {"L1_GAS": {"max_amount": "0x4c4b40", "max_price_per_unit": "0x5af3107a4000"}, "L2_GAS": {"max_amount": "0x0", "max_price_per_unit": "0x0"}}, "tip": "0x0", "paymaster_data": [], "sender_address": "0x14c5c28581c68f64c9a3d86b919094a5209fe0ccb454f776b3be2c3968cd91d", "calldata": ["0x2", "0x1305509ce387ad1b83a47c85a0ff3e82cb3be71f39e8c8753589f10f60ecde4", "0x1a8e87e9d2008fcd3ce423ae5219c21e49be18d05d72825feb7e2bb687ba35c", "0x2", "0xa5bbc76ce4df888a29eda0b0a330ab03", "0x60b205737c37d74ad955261cbadab5a", "0x1305509ce387ad1b83a47c85a0ff3e82cb3be71f39e8c8753589f10f60ecde4", "0x2fd9126ee011f3a837cea02e32ae4ee73342d827e216998e5616bab88d8b7ea", "0x1", "0x2fd9126ee011f3a837cea02e32ae4ee73342d827e216998e5616bab88d8b7ea"], "account_deployment_data": [], "type": "INVOKE_FUNCTION"}, {"transaction_hash": "0x176d3c945cfd1617a173023dd08904964a28d4047207a55890d535ecebeb855", "version": "0x3", "signature": ["0x64ac3d82149ae762db30b40a7bf62bcdda3e7766a50b277ab8fc310a5fa7573", "0xaf92c9be805d0032253e7bacbd0ac374e50e5a81dfd473c5f34a132b49592f"], "nonce": "0xd0f", "nonce_data_availability_mode": 0, "fee_data_availability_mode": 0, "resource_bounds": {"L1_GAS": {"max_amount": "0x4c4b40", "max_price_per_unit": "0x5af3107a4000"}, "L2_GAS": {"max_amount": "0x0", "max_price_per_unit": "0x0"}}, "tip": "0x0", "paymaster_data": [], "sender_address": "0x14c5c28581c68f64c9a3d86b919094a5209fe0ccb454f776b3be2c3968cd91d", "calldata": ["0x2", "0x1305509ce387ad1b83a47c85a0ff3e82cb3be71f39e8c8753589f10f60ecde4", "0x1136789e1c76159d9b9eca06fcef05bdcf77f5d51bd4d9e09f2bc8d7520d8e6", "0x2", "0x5b4484f4c3ac6b3e36f40d58b8a4898f", "0x47ed253dc74560135faa58a3f5b1dafd", "0x4e18c9f8a657466bfe60e23e590fc1e60cb465bf6a8ca8587b6a35f3b53db20", "0x1a8e87e9d2008fcd3ce423ae5219c21e49be18d05d72825feb7e2bb687ba35c", "0x2", "0x98c0f992deda4c98c7c897429c4a0bef", "0xd65041cb57428e00fcd0493c36ebf439"], "account_deployment_data": [], "type": "INVOKE_FUNCTION"}, {"transaction_hash": "0x1026a5617deaf998b8cd2ee8c74ccee9691bedbdcabb20681f148918a67c579", "version": "0x1", "max_fee": "0x354a6ba7a18000", "signature": ["0x789e321106ca0461f6cb87c402b16ab728bcc9585f5c2933e3a1eafe388318a", "0x68832f809f3eeda9b3605436337d8e65a96705cd4837edd48bcba7dc60bb75e"], "nonce": "0xd10", "sender_address": "0x14c5c28581c68f64c9a3d86b919094a5209fe0ccb454f776b3be2c3968cd91d", "calldata": ["0x2", "0x232438a37dc1e45f6cf278b308db7d1868016a5a6a2f6c4d3da746b4d13d891", "0x3d7905601c217734671143d457f0db37f7f8883112abd34b92c4abfeafde0c3", "0x2", "0x4cbc5a746176a23a47175d24e8649e04e2964ecc03bc1acbc7bffe874f42d29", "0x476f6db708731413479d252509fc9f09287ae8bc0f950e1d9cb2a104df3f1d4", "0x3b73e1773ce95172c5f525f29d4d1eb2b407429559bceaa7dec815deb6c0028", "0x2913ee03e5e3308c41e308bd391ea4faac9b9cb5062c76a6b3ab4f65397e106", "0xb", "0x7", "0x18211d912741bc54c285b2d9e064677d9583d23d1c13cd6315badbb075631f3", "0x616a09e59f254563a69a8ec20eabbf00f63ab8298ec88b70bbe32b72cc64699", "0x6967836d5ad89ce9d3ae655ceb419900910450d32a5c258ae81cd8f45f44e5d", "0x14f718f63db1f6b0485079a6100b7ffc9e28916799c1df3b57088a8bb2a9789", "0x353a201b0153a4e83ba63adfc59e952dcc5b59d9c99cda7b941b544fdca845a", "0x171f281c5b58f4e8065c0a62ed1d593509a8716b239af914b96556cc7c50845", "0x345fd24f3305953bcd73901a2948cc4f8dde03373f893d2f310491bf0773c8c", "0x2", "0x1aa3586a2df68cdd16b828652af188839a563222f2f554602eca15b99988ce", "0x7f7f98f280212b5dabcf57d77cc81f9ce1f4d9e1d72c3c24df954edf98b7725"], "type": "INVOKE_FUNCTION"}, {"transaction_hash": "0x4c2d8153bc1869b19e72cc54e093dab2e3ceb1ade34b0a7b3200259dcfa03f2", "version": "0x1", "max_fee": "0x354a6ba7a18000", "signature": ["0x4d82a74f09ddef3863f7185707bbdf7e14e47bdbe72c24ad6c5bbc1064a2213", "0x100f5c4cd679818b1a79922b8e26dc4c9d0ddba213e0669b212c3e24b6d255c"], "nonce": "0xd11", "sender_address": "0x14c5c28581c68f64c9a3d86b919094a5209fe0ccb454f776b3be2c3968cd91d", "calldata": ["0x2", "0x4e18c9f8a657466bfe60e23e590fc1e60cb465bf6a8ca8587b6a35f3b53db20", "0x2468d193cd15b621b24c2a602b8dbcfa5eaa14f88416c40c09d7fd12592cb4b", "0x0", "0x1305509ce387ad1b83a47c85a0ff3e82cb3be71f39e8c8753589f10f60ecde4", "0x1136789e1c76159d9b9eca06fcef05bdcf77f5d51bd4d9e09f2bc8d7520d8e6", "0x2", "0x22ba9c150f70a0710980f011720f8bcf", "0x9859d9b143ea8473a96ca0f0cae406d4"], "type": "INVOKE_FUNCTION"}], "timestamp": 1708331964, "sequencer_address": "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", "transaction_receipts": [{"execution_status": "SUCCEEDED", "transaction_index": 0, "transaction_hash": "0x1ffcecfdae93215db398482d3e91e065816bdeda116ef8d3e68f2f6c01a0e22", "l2_to_l1_messages": [], "events": [{"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9", "0x14c5c28581c68f64c9a3d86b919094a5209fe0ccb454f776b3be2c3968cd91d", "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"], "data": ["0x1e5204243c0", "0x0"]}, {"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0xa9fa878c35cd3d0191318f89033ca3e5501a3d90e21e3cc9256bdd5cd17fdd"], "data": ["0xca46d96b37266650e0a8b79938d9300037337cad82ea4f45a921ad68b6a5f9", "0x265ebac9efe21a8d", "0x0", "0x265ebcaf10245e4d", "0x0"]}], "execution_resources": {"n_steps": 10432, "builtin_instance_counter": {"ec_op_builtin": 3, "range_check_builtin": 421, "pedersen_builtin": 24}, "n_memory_holes": 0, "data_availability": {"l1_gas": 0, "l1_data_gas": 128}}, "actual_fee": "0x1e5204243c0"}, {"execution_status": "SUCCEEDED", "transaction_index": 1, "transaction_hash": "0x176d3c945cfd1617a173023dd08904964a28d4047207a55890d535ecebeb855", "l2_to_l1_messages": [], "events": [{"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9", "0x14c5c28581c68f64c9a3d86b919094a5209fe0ccb454f776b3be2c3968cd91d", "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"], "data": ["0x1e67bc11f40", "0x0"]}, {"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d", "keys": ["0xa9fa878c35cd3d0191318f89033ca3e5501a3d90e21e3cc9256bdd5cd17fdd"], "data": ["0xca46d96b37266650e0a8b79938d9300037337cad82ea4f45a921ad68b6a5f9", "0x265ebcaf10245e4d", "0x0", "0x265ebe958be57d8d", "0x0"]}], "execution_resources": {"n_steps": 13918, "builtin_instance_counter": {"pedersen_builtin": 25, "ec_op_builtin": 3, "range_check_builtin": 708}, "n_memory_holes": 0, "data_availability": {"l1_gas": 0, "l1_data_gas": 128}}, "actual_fee": "0x1e67bc11f40"}, {"execution_status": "SUCCEEDED", "transaction_index": 2, "transaction_hash": "0x1026a5617deaf998b8cd2ee8c74ccee9691bedbdcabb20681f148918a67c579", "l2_to_l1_messages": [], "events": [{"from_address": "0x3b73e1773ce95172c5f525f29d4d1eb2b407429559bceaa7dec815deb6c0028", "keys": ["0x18211d912741bc54c285b2d9e064677d9583d23d1c13cd6315badbb075631f3", "0x616a09e59f254563a69a8ec20eabbf00f63ab8298ec88b70bbe32b72cc64699", "0x6967836d5ad89ce9d3ae655ceb419900910450d32a5c258ae81cd8f45f44e5d", "0x14f718f63db1f6b0485079a6100b7ffc9e28916799c1df3b57088a8bb2a9789", "0x353a201b0153a4e83ba63adfc59e952dcc5b59d9c99cda7b941b544fdca845a", "0x171f281c5b58f4e8065c0a62ed1d593509a8716b239af914b96556cc7c50845", "0x345fd24f3305953bcd73901a2948cc4f8dde03373f893d2f310491bf0773c8c"], "data": ["0x1aa3586a2df68cdd16b828652af188839a563222f2f554602eca15b99988ce", "0x7f7f98f280212b5dabcf57d77cc81f9ce1f4d9e1d72c3c24df954edf98b7725"]}], "execution_resources": {"n_steps": 7254, "builtin_instance_counter": {"ec_op_builtin": 3, "range_check_builtin": 186, "pedersen_builtin": 34}, "n_memory_holes": 0, "data_availability": {"l1_gas": 0, "l1_data_gas": 256}}, "actual_fee": "0x52b3dc781d2"}, {"execution_status": "SUCCEEDED", "transaction_index": 3, "transaction_hash": "0x4c2d8153bc1869b19e72cc54e093dab2e3ceb1ade34b0a7b3200259dcfa03f2", "l2_to_l1_messages": [], "events": [], "execution_resources": {"n_steps": 10625, "builtin_instance_counter": {"range_check_builtin": 474, "poseidon_builtin": 1, "pedersen_builtin": 23, "ec_op_builtin": 3}, "n_memory_holes": 0, "data_availability": {"l1_gas": 0, "l1_data_gas": 128}}, "actual_fee": "0x299b1f89098"}], "starknet_version": "0.13.1"}
1 change: 1 addition & 0 deletions clients/feeder/testdata/integration/signature/330363.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"block_number": 330363, "signature": ["0x7685fbcd4bacae7554ad17c6962221143911d894d7b8794d29234623f392562", "0x343e605de3957e664746ba8ef82f2b0f9d53cda3d75dcb078290b8edd010165"], "signature_input": {"block_hash": "0x8ab8117e952f95efd96de0bc66dc6f13fe68dfda14b95fe1972759dee283a8", "state_diff_commitment": "0x2661bc5a84a6ee84586df7aa9d3fc084df80d46bfd873e03ec46352a1886fc"}}
17 changes: 14 additions & 3 deletions core/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,24 @@ type Header struct {
L1GasPrice *GasPrice
}

type L1DAMode string
type L1DAMode int

const (
CallData L1DAMode = "CALLDATA"
Blob L1DAMode = "BLOB"
L1DAModeCALLDATA L1DAMode = iota + 1
L1DAModeBLOB
)

func (l L1DAMode) String() string {
switch l {
case L1DAModeCALLDATA:
return "CALLDATA"
case L1DAModeBLOB:
return "BLOB"
default:
return ""

Check warning on line 64 in core/block.go

View check run for this annotation

Codecov / codecov/patch

core/block.go#L57-L64

Added lines #L57 - L64 were not covered by tests
}
}

type GasPrice struct {
PriceInWei *felt.Felt
PriceInFri *felt.Felt
Expand Down

0 comments on commit d0d4ce0

Please sign in to comment.