Skip to content

Commit

Permalink
Fix Bubblegum script testing and add unverify_creator and `update_m…
Browse files Browse the repository at this point in the history
…etadata` test scenarios using devnet txs (metaplex-foundation#165)
  • Loading branch information
danenbm authored Jan 28, 2024
1 parent 1ca4534 commit 5d69bfc
Show file tree
Hide file tree
Showing 39 changed files with 484 additions and 85 deletions.
37 changes: 24 additions & 13 deletions tools/txn_forwarder/bubblegum_tests/run-bubblegum-sequences.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
#!/bin/bash

# Pass `reverse` to run scenarios in reverse.
if [ "$1" = "reverse" ]; then
REVERSE="true"
else
REVERSE="false"
fi
case $1 in
"reverse"|"--reverse"|"-r")
REVERSE="true"
;;
*)
REVERSE="false"
;;
esac

SCENARIOS=("mint_transfer_burn.scenario" \
"mint_redeem_decompress.scenario"
"mint_redeem_cancel_redeem_redeem_decompress.scenario" \
"mint_transfer_transfer.scenario" \
"mint_delegate_transfer.scenario" \
"mint_verify_creator.scenario" \
"mint_unverify_creator.scenario" \
"mint_verify_collection.scenario" \
"mint_verify_collection_unverify_collection.scenario" \
"mint_set_and_verify_collection.scenario" \
"mint_to_collection_unverify_collection.scenario"
"mint_to_collection_unverify_collection.scenario" \
"mint_verify_creator_unverify_creator_update_metadata.scenario" \
"mint_update_metadata_creator_position_3_to_2.scenario" \
"mint_update_metadata_remove_all_creators.scenario"
)

TEST_SCENARIO_DATA_DIR="test_scenario_data"
Expand Down Expand Up @@ -59,13 +66,6 @@ CHECK_DATABASE() {
# If successful, prints contents of file on stdout and returns 0, otherwise returns 1.
READ_IN_EXPECTED_DATA() {
local BASE_NAME=$(basename "$1" .scenario)
if [ "$REVERSE" = "true" ]; then
local EXPECTED_DATA_FILE_BW="$TEST_SCENARIO_DATA_DIR/${BASE_NAME}_"$2"_reverse.txt"
if [ -f "$EXPECTED_DATA_FILE_BW" ]; then
cat "$EXPECTED_DATA_FILE_BW"
return 0
fi
fi

local EXPECTED_DATA_FILE="$TEST_SCENARIO_DATA_DIR/${BASE_NAME}_"$2".txt"
if [ -f "$EXPECTED_DATA_FILE" ]; then
Expand All @@ -90,6 +90,7 @@ STATUS=0
for i in ${!SCENARIOS[@]}; do
# Read in the expected database data for this scenario.
EXPECTED_ASSET_VALUE=$(READ_IN_EXPECTED_DATA "${SCENARIOS[$i]}" "asset") || { STATUS=1; continue; }
EXPECTED_ASSET_DATA_VALUE=$(READ_IN_EXPECTED_DATA "${SCENARIOS[$i]}" "asset_data") || { STATUS=1; continue; }
EXPECTED_ASSET_CREATORS=$(READ_IN_EXPECTED_DATA "${SCENARIOS[$i]}" "asset_creators") || { STATUS=1; continue; }
EXPECTED_ASSET_GROUPING=$(READ_IN_EXPECTED_DATA "${SCENARIOS[$i]}" "asset_grouping") || { STATUS=1; continue; }
EXPECTED_CL_ITEMS=$(READ_IN_EXPECTED_DATA "${SCENARIOS[$i]}" "cl_items") || { STATUS=1; continue; }
Expand All @@ -116,6 +117,9 @@ for i in ${!SCENARIOS[@]}; do
ASSET_SQL="SELECT * FROM asset WHERE id = '$ASSET_ID';"
CHECK_DATABASE "$ASSET_SQL" "-x" "(0 rows)" "initial asset table state" || STATUS=1

ASSET_DATA_SQL="SELECT * FROM asset_data WHERE id = '$ASSET_ID';"
CHECK_DATABASE "$ASSET_DATA_SQL" "-x" "(0 rows)" "initial asset table state" || STATUS=1

ASSET_CREATORS_SQL="SELECT asset_id, creator, share, verified, seq, slot_updated, position \
FROM asset_creators \
WHERE asset_id = '$ASSET_ID' \
Expand All @@ -134,6 +138,12 @@ for i in ${!SCENARIOS[@]}; do
# in order to enforce order. Just calling the `txn_forwarder` with the file results in random ordering.
readarray -t TXS < "$TEST_SCENARIO_DATA_DIR/${SCENARIOS[$i]}"

if [ ${#TXS[@]} = 0 ]; then
echo $(RED "No scenarios found for ${SCENARIOS[$i]}!")
STATUS=1
continue
fi

# Reverse transactions if necessary.
if [ "$REVERSE" = "true" ]; then
REVERSED_TXS=()
Expand All @@ -157,6 +167,7 @@ for i in ${!SCENARIOS[@]}; do

# Asset should now be in the database and all fields match (except `created_at` in `asset`` table).
CHECK_DATABASE "$ASSET_SQL" "-x" "$EXPECTED_ASSET_VALUE" "asset table" || STATUS=1
CHECK_DATABASE "$ASSET_DATA_SQL" "-x" "$EXPECTED_ASSET_DATA_VALUE" "asset_data table" || STATUS=1
CHECK_DATABASE "$ASSET_CREATORS_SQL" "-x" "$EXPECTED_ASSET_CREATORS" "asset_creators table" || STATUS=1
CHECK_DATABASE "$ASSET_GROUPING_SQL" "-x" "$EXPECTED_ASSET_GROUPING" "asset_grouping table" || STATUS=1
CHECK_DATABASE "$CL_ITEMS_SQL" "" "$EXPECTED_CL_ITEMS" "cl_items table" || STATUS=1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------------------------------------------------
id | \x5aed3f1d3faf9f5f4664f98055d25627d59d0351ee8f0802ebbb33ccd8220d67
chain_data_mutability | immutable
chain_data | {"name": "test", "symbol": "TST", "edition_nonce": 0, "token_standard": "NonFungible", "primary_sale_happened": false}
metadata_url | https://metaplex.com
metadata_mutability | mutable
metadata | "processing"
slot_updated | 226274127
reindex | t
raw_name | \x74657374
raw_symbol | \x545354
base_info_seq | 1
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ owner_type | single
delegate |
frozen | f
supply | 1
supply_mint | \x4302561a2799244936a3b020569bf90f58cd9b406af4cd084a82a2cf6415a8f0
compressed | f
supply_mint |
compressed | t
compressible | f
seq | 0
tree_id |
leaf |
seq | 4
tree_id | \xf8bf1069ff226eb41797417535cc5510ec75ffd006155dbda2371b5fee88bf7d
leaf | \x0000000000000000000000000000000000000000000000000000000000000000
nonce | 0
royalty_target_type | creators
royalty_target |
royalty_amount | 0
asset_data | \x4302561a2799244936a3b020569bf90f58cd9b406af4cd084a82a2cf6415a8f0
burnt | f
slot_updated | 224494461
data_hash |
creator_hash |
data_hash | 11111111111111111111111111111111
creator_hash | 11111111111111111111111111111111
owner_delegate_seq | 3
leaf_seq |
leaf_seq | 4
base_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------------------------------------------------
id | \x4302561a2799244936a3b020569bf90f58cd9b406af4cd084a82a2cf6415a8f0
chain_data_mutability | immutable
chain_data | {"name": "test", "symbol": "TST", "edition_nonce": 0, "token_standard": "NonFungible", "primary_sale_happened": false}
metadata_url | https://metaplex.com
metadata_mutability | mutable
metadata | "processing"
slot_updated | 224494461
reindex | t
raw_name | \x74657374
raw_symbol | \x545354
base_info_seq | 1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ owner_type | single
delegate |
frozen | f
supply | 1
supply_mint | \x4582ef313005487b924213937300a3c5cef8502646c8c182a2a9e1188adb196b
compressed | f
supply_mint |
compressed | t
compressible | f
seq | 0
tree_id |
leaf |
seq | 2
tree_id | \x85de015db25b997c2c2dc80baa680016bf82c1d748a1c69361a54daee5c4e561
leaf | \x0000000000000000000000000000000000000000000000000000000000000000
nonce | 0
royalty_target_type | creators
royalty_target |
royalty_amount | 0
asset_data | \x4582ef313005487b924213937300a3c5cef8502646c8c182a2a9e1188adb196b
burnt | f
slot_updated | 224069842
data_hash |
creator_hash |
data_hash | 11111111111111111111111111111111
creator_hash | 11111111111111111111111111111111
owner_delegate_seq | 1
leaf_seq |
leaf_seq | 2
base_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------------------------------------------------
id | \x4582ef313005487b924213937300a3c5cef8502646c8c182a2a9e1188adb196b
chain_data_mutability | immutable
chain_data | {"name": "test", "symbol": "TST", "edition_nonce": 0, "token_standard": "NonFungible", "primary_sale_happened": false}
metadata_url | https://metaplex.com
metadata_mutability | mutable
metadata | "processing"
slot_updated | 224069842
reindex | t
raw_name | \x74657374
raw_symbol | \x545354
base_info_seq | 1

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------------------------------------------------
id | \x1679ec700d2cf85da62294237cedf6b7c57ea3a28940ec152c3c6a65c271f9a3
chain_data_mutability | immutable
chain_data | {"name": "test", "symbol": "TST", "edition_nonce": 0, "token_standard": "NonFungible", "primary_sale_happened": false}
metadata_url | https://metaplex.com
metadata_mutability | mutable
metadata | "processing"
slot_updated | 232170413
reindex | t
raw_name | \x74657374
raw_symbol | \x545354
base_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------------------------------------------------
id | \x18e8b7e61a39441667dc71c6c44b0a7966612af1428740bb00dcce262ba00673
chain_data_mutability | immutable
chain_data | {"name": "test", "symbol": "TST", "edition_nonce": 0, "token_standard": "NonFungible", "primary_sale_happened": false}
metadata_url | https://metaplex.com
metadata_mutability | mutable
metadata | "processing"
slot_updated | 232178646
reindex | t
raw_name | \x74657374
raw_symbol | \x545354
base_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------------------------------------------------
id | \x75d2c89f62f8a50ed994309655bbd27de2c5f0b3da4cf8c329320016b47aa3d1
chain_data_mutability | immutable
chain_data | {"name": "test", "symbol": "TST", "edition_nonce": 0, "token_standard": "NonFungible", "primary_sale_happened": false}
metadata_url | https://metaplex.com
metadata_mutability | mutable
metadata | "processing"
slot_updated | 221559431
reindex | t
raw_name | \x74657374
raw_symbol | \x545354
base_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------------------------------------------------
id | \xca35c69cd4d5bb853a93e4e76526be26cf5951982653cf653d9dddac5e5ac797
chain_data_mutability | immutable
chain_data | {"name": "test", "symbol": "TST", "edition_nonce": 0, "token_standard": "NonFungible", "primary_sale_happened": false}
metadata_url | https://metaplex.com
metadata_mutability | mutable
metadata | "processing"
slot_updated | 224501105
reindex | t
raw_name | \x74657374
raw_symbol | \x545354
base_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
9p6KdujGH7QrHf83kU72QFj7RopnBAa9kgJTqR23uf5dcBbRz12guig8bBjnhAF9qymjG8ukLG3Khgyus7Hj2PJ
3zxBpoudkNtmnHEDLg5jyfHuRJhFz6HiUxa1g8pqLUyboYCbmGRqAq1h85SDpESETxdtPo17BPDtTQS2YHqQKaao
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-[ RECORD 1 ]-------------+-------------------------------------------------------------------
id | \xdee18b450d1a279ad5ab41f17c2daccbf827f82113c32f08573872ef05869cb8
alt_id |
specification_version | v1
specification_asset_class | NFT
owner | \xdc53343c46e5d7a1bd08f4780285621202f66b596f984e940a5eb423ac560fed
owner_type | single
delegate |
frozen | f
supply | 1
supply_mint |
compressed | t
compressible | f
seq | 2
tree_id | \x20fbd4120c7aa919cd7eeb145c35cbec14742170df1361e0c1504c278ecf0dbb
leaf | \x162ee13e1c60c989dd3834618aece0a3a7f6b24b4815bb7f8eb8a186dd11867d
nonce | 0
royalty_target_type | creators
royalty_target |
royalty_amount | 0
asset_data | \xdee18b450d1a279ad5ab41f17c2daccbf827f82113c32f08573872ef05869cb8
burnt | f
slot_updated | 275704003
data_hash | BVPXiaGg74xazp8NvjtE6ypLeMsSwSt6Cvc7V2FJvmXd
creator_hash | 6CTqFz9shqciWHtCeeS2kQwtctm6mZbkUjFtPpP51VvW
owner_delegate_seq | 2
leaf_seq | 2
base_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-[ RECORD 1 ]+-------------------------------------------------------------------
asset_id | \xdee18b450d1a279ad5ab41f17c2daccbf827f82113c32f08573872ef05869cb8
creator | \xdc53343c46e5d7a1bd08f4780285621202f66b596f984e940a5eb423ac560fed
share | 100
verified | f
seq | 2
slot_updated | 275704005
position | 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------------------------------------------------
id | \xdee18b450d1a279ad5ab41f17c2daccbf827f82113c32f08573872ef05869cb8
chain_data_mutability | mutable
chain_data | {"name": "test", "symbol": "TST", "edition_nonce": 0, "token_standard": "NonFungible", "primary_sale_happened": false}
metadata_url | https://metaplex.com
metadata_mutability | mutable
metadata | "processing"
slot_updated | 275704003
reindex | t
raw_name | \x74657374
raw_symbol | \x545354
base_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-[ RECORD 1 ]--+-------------------------------------------------------------------
asset_id | \xdee18b450d1a279ad5ab41f17c2daccbf827f82113c32f08573872ef05869cb8
group_key | collection
group_value |
seq |
slot_updated | 275704003
verified | f
group_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tree | node_idx | leaf_idx | seq | level | hash
--------------------------------------------------------------------+----------+----------+-----+-------+--------------------------------------------------------------------
\x20fbd4120c7aa919cd7eeb145c35cbec14742170df1361e0c1504c278ecf0dbb | 8 | 0 | 2 | 0 | \x162ee13e1c60c989dd3834618aece0a3a7f6b24b4815bb7f8eb8a186dd11867d
\x20fbd4120c7aa919cd7eeb145c35cbec14742170df1361e0c1504c278ecf0dbb | 4 | | 2 | 1 | \xab9b631b333d83a92c4c943113ea0dc9d26e7eb7b056a762eb7dbeeb5a40ee53
\x20fbd4120c7aa919cd7eeb145c35cbec14742170df1361e0c1504c278ecf0dbb | 2 | | 2 | 2 | \x7c1e4d6f2b2aa08d4d19b688c43352ecf568029805ca0feeea1cafea967747e8
\x20fbd4120c7aa919cd7eeb145c35cbec14742170df1361e0c1504c278ecf0dbb | 1 | | 2 | 3 | \x9f9b18c1be658a116eb083b5d58365bc9519e1a8c0e7b79c235c65588dff707d
(4 rows)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2DP84v6Pi3e4v5i7KSvzmK4Ufbzof3TAiEqDbm9gg8jZpBRF9f1Cy6x54kvZoHPX9k1XfqbsG1FTv2KVP9fvNrN6
3bsL5zmLKvhN9Je4snTKxjFSpmXEEg2cvMHm2rCNgaEYkNXBqJTA4N7QmvBSWPiNUQPtzJSYzpQYX92NowV3L7vN
Loading

0 comments on commit 5d69bfc

Please sign in to comment.