Skip to content

Commit

Permalink
Add asset_creators and asset_grouping tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Jan 3, 2024
1 parent 9f2adc6 commit b8ba360
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-[ RECORD 1 ]+-------------------------------------------------------------------
asset_id | \x5aed3f1d3faf9f5f4664f98055d25627d59d0351ee8f0802ebbb33ccd8220d67
creator | \xdc53343c46e5d7a1bd08f4780285621202f66b596f984e940a5eb423ac560fed
share | 55
verified | f
seq | 1
slot_updated | 226274127
position | 0
-[ RECORD 2 ]+-------------------------------------------------------------------
asset_id | \x5aed3f1d3faf9f5f4664f98055d25627d59d0351ee8f0802ebbb33ccd8220d67
creator | \xe3dc3480d88f714c38827aada3064e8d212a91e3fdb67f22438c1ed89318a0e5
share | 45
verified | f
seq | 1
slot_updated | 226274127
position | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-[ RECORD 1 ]--+-------------------------------------------------------------------
asset_id | \x5aed3f1d3faf9f5f4664f98055d25627d59d0351ee8f0802ebbb33ccd8220d67
group_key | collection
group_value |
seq |
slot_updated | 226274127
verified | f
group_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-[ RECORD 1 ]+-------------------------------------------------------------------
asset_id | \x4302561a2799244936a3b020569bf90f58cd9b406af4cd084a82a2cf6415a8f0
creator | \xdc53343c46e5d7a1bd08f4780285621202f66b596f984e940a5eb423ac560fed
share | 55
verified | f
seq | 1
slot_updated | 224494461
position | 0
-[ RECORD 2 ]+-------------------------------------------------------------------
asset_id | \x4302561a2799244936a3b020569bf90f58cd9b406af4cd084a82a2cf6415a8f0
creator | \xe6cd5c15dc19a877bc4bdf888a32145bd007f3a6ad52243937ffe41e3c2e7c3e
share | 45
verified | f
seq | 1
slot_updated | 224494461
position | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-[ RECORD 1 ]--+-------------------------------------------------------------------
asset_id | \x4302561a2799244936a3b020569bf90f58cd9b406af4cd084a82a2cf6415a8f0
group_key | collection
group_value |
seq |
slot_updated | 224494461
verified | f
group_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-[ RECORD 1 ]+-------------------------------------------------------------------
asset_id | \x4582ef313005487b924213937300a3c5cef8502646c8c182a2a9e1188adb196b
creator | \xdc53343c46e5d7a1bd08f4780285621202f66b596f984e940a5eb423ac560fed
share | 55
verified | f
seq | 1
slot_updated | 224069842
position | 0
-[ RECORD 2 ]+-------------------------------------------------------------------
asset_id | \x4582ef313005487b924213937300a3c5cef8502646c8c182a2a9e1188adb196b
creator | \xfcd064cd56ad840b463ca2ee1f6e13b6181cbb7464699dbfe18fe989e71def89
share | 45
verified | f
seq | 1
slot_updated | 224069842
position | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-[ RECORD 1 ]--+-------------------------------------------------------------------
asset_id | \x4582ef313005487b924213937300a3c5cef8502646c8c182a2a9e1188adb196b
group_key | collection
group_value |
seq |
slot_updated | 224069842
verified | f
group_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-[ RECORD 1 ]+-------------------------------------------------------------------
asset_id | \x75d2c89f62f8a50ed994309655bbd27de2c5f0b3da4cf8c329320016b47aa3d1
creator | \xdc53343c46e5d7a1bd08f4780285621202f66b596f984e940a5eb423ac560fed
share | 55
verified | f
seq | 1
slot_updated | 221559431
position | 0
-[ RECORD 2 ]+-------------------------------------------------------------------
asset_id | \x75d2c89f62f8a50ed994309655bbd27de2c5f0b3da4cf8c329320016b47aa3d1
creator | \xab4ea130077985e7bae2df6a4aa90c94a2918c7bec1ccf44ab994c6803f5e8d2
share | 45
verified | f
seq | 1
slot_updated | 221559431
position | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-[ RECORD 1 ]--+-------------------------------------------------------------------
asset_id | \x75d2c89f62f8a50ed994309655bbd27de2c5f0b3da4cf8c329320016b47aa3d1
group_key | collection
group_value |
seq |
slot_updated | 221559431
verified | f
group_info_seq | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-[ RECORD 1 ]+-------------------------------------------------------------------
asset_id | \xca35c69cd4d5bb853a93e4e76526be26cf5951982653cf653d9dddac5e5ac797
creator | \xdc53343c46e5d7a1bd08f4780285621202f66b596f984e940a5eb423ac560fed
share | 55
verified | f
seq | 1
slot_updated | 224501105
position | 0
-[ RECORD 2 ]+-------------------------------------------------------------------
asset_id | \xca35c69cd4d5bb853a93e4e76526be26cf5951982653cf653d9dddac5e5ac797
creator | \x900de0b94569cfed833ae4c2ca61ba796f44334823c57a58be5661585fd8f2e2
share | 45
verified | f
seq | 1
slot_updated | 224501105
position | 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-[ RECORD 1 ]--+-------------------------------------------------------------------
asset_id | \xca35c69cd4d5bb853a93e4e76526be26cf5951982653cf653d9dddac5e5ac797
group_key | collection
group_value |
seq |
slot_updated | 224501105
verified | f
group_info_seq | 1
80 changes: 75 additions & 5 deletions tools/txn_forwarder/bubblegum_tests/run-bubblegum-sequences.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,58 @@ for i in ${!SCENARIOS[@]}; do
fi

# Initially this asset should not be in `asset`` table.
SQL="select * from asset where id = '$ASSET_ID';"
DATABASE_VAL=$(PGPASSWORD=solana psql -h localhost -U solana -x --command="$SQL")
ASSET_SQL="SELECT * FROM asset WHERE id = '$ASSET_ID';"
DATABASE_VAL=$(PGPASSWORD=solana psql -h localhost -U solana -x --command="$ASSET_SQL")
if [ "(0 rows)" == "$DATABASE_VAL" ]; then
echo $(GRN "${SCENARIOS[$i]} initial asset table passed")
else
echo $(RED "${SCENARIOS[$i]} initial asset table failed")
STATUS=1
fi

# Read in the `asset_creators` file for this scenario.
EXPECTED_ASSET_CREATORS_FILE="$(basename "${SCENARIOS[$i]}" .scenario)_asset_creators.txt"
if [ ! -f "$EXPECTED_ASSET_CREATORS_FILE" ]; then
echo $(RED "${SCENARIOS[$i]} missing asset_creators file")
STATUS=1
continue
fi
EXPECTED_ASSET_CREATORS=$(<"$EXPECTED_ASSET_CREATORS_FILE")

# Initially this asset should not be in `asset_creators`` table.
ASSET_CREATORS_SQL="SELECT asset_id, creator, share, verified, seq, slot_updated, position \
FROM asset_creators \
WHERE asset_id = '$ASSET_ID' \
ORDER BY position;"
DATABASE_VAL=$(PGPASSWORD=solana psql -h localhost -U solana -x --command="$ASSET_CREATORS_SQL")
if [ "(0 rows)" == "$DATABASE_VAL" ]; then
echo $(GRN "${SCENARIOS[$i]} initial asset_creators table passed")
else
echo $(RED "${SCENARIOS[$i]} initial asset_creators table failed")
STATUS=1
fi

# Read in the `asset_grouping` file for this scenario.
EXPECTED_ASSET_GROUPING_FILE="$(basename "${SCENARIOS[$i]}" .scenario)_asset_grouping.txt"
if [ ! -f "$EXPECTED_ASSET_GROUPING_FILE" ]; then
echo $(RED "${SCENARIOS[$i]} missing asset_grouping file")
STATUS=1
continue
fi
EXPECTED_ASSET_GROUPING=$(<"$EXPECTED_ASSET_GROUPING_FILE")

# Initially this asset should not be in `asset_grouping`` table.
ASSET_GROUPING_SQL="SELECT asset_id, group_key, group_value, seq, slot_updated, verified, group_info_seq \
FROM asset_grouping \
WHERE asset_id = '$ASSET_ID';"
DATABASE_VAL=$(PGPASSWORD=solana psql -h localhost -U solana -x --command="$ASSET_GROUPING_SQL")
if [ "(0 rows)" == "$DATABASE_VAL" ]; then
echo $(GRN "${SCENARIOS[$i]} initial asset_grouping table passed")
else
echo $(RED "${SCENARIOS[$i]} initial asset_grouping table failed")
STATUS=1
fi

# Read in the `cl_items` file for this scenario.
EXPECTED_CL_ITEMS_FILE="$(basename "${SCENARIOS[$i]}" .scenario)_cl_items.txt"
if [ ! -f "$EXPECTED_CL_ITEMS_FILE" ]; then
Expand Down Expand Up @@ -95,9 +138,8 @@ for i in ${!SCENARIOS[@]}; do

sleep 3

# Asset should now be in `asset`` table and all fields except `created_at` date match.
SQL="select * from asset where id = '$ASSET_ID';"
DATABASE_VAL=$(PGPASSWORD=solana psql -h localhost -U solana -x --command="$SQL")
# Asset should now be in `asset` table and all fields except `created_at` date match.
DATABASE_VAL=$(PGPASSWORD=solana psql -h localhost -U solana -x --command="$ASSET_SQL")
DATABASE_VAL_NO_DATE=$(sed '/^created_at/d' <<< "$DATABASE_VAL")
if [ "$EXPECTED_ASSET_VALUE" == "$DATABASE_VAL_NO_DATE" ]; then
echo $(GRN "${SCENARIOS[$i]} asset table passed")
Expand All @@ -111,6 +153,34 @@ for i in ${!SCENARIOS[@]}; do
STATUS=1
fi

# Asset should now be in `asset_creators` table and all fields match.
DATABASE_VAL=$(PGPASSWORD=solana psql -h localhost -U solana -x --command="$ASSET_CREATORS_SQL")
if [ "$EXPECTED_ASSET_CREATORS" == "$DATABASE_VAL" ]; then
echo $(GRN "${SCENARIOS[$i]} asset_creators table passed")
else
echo $(RED "${SCENARIOS[$i]} asset_creators table failed")
echo "Asset ID: $ASSET_ID"
echo "Expected:"
echo "$EXPECTED_ASSET_CREATORS"
echo "Actual:"
echo "$DATABASE_VAL"
STATUS=1
fi

# Asset should now be in `asset_grouping` table and all fields match.
DATABASE_VAL=$(PGPASSWORD=solana psql -h localhost -U solana -x --command="$ASSET_GROUPING_SQL")
if [ "$EXPECTED_ASSET_GROUPING" == "$DATABASE_VAL" ]; then
echo $(GRN "${SCENARIOS[$i]} asset_grouping table passed")
else
echo $(RED "${SCENARIOS[$i]} asset_grouping table failed")
echo "Asset ID: $ASSET_ID"
echo "Expected:"
echo "$EXPECTED_ASSET_GROUPING"
echo "Actual:"
echo "$DATABASE_VAL"
STATUS=1
fi

# Tree should now be in `cl_items`` table and all fields match.
SQL="select tree, node_idx, leaf_idx, seq, level, hash from cl_items where tree = '$TREE_ID' order by level;"
DATABASE_VAL=$(PGPASSWORD=solana psql -h localhost -U solana --command="$SQL")
Expand Down

0 comments on commit b8ba360

Please sign in to comment.