Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfind committed Jan 7, 2025
1 parent eb0c0ee commit b632f95
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 118 deletions.
22 changes: 14 additions & 8 deletions crates/sui-indexer-alt/src/handlers/coin_balance_buckets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,15 @@ mod tests {

#[test]
fn test_process_coin_balance_buckets_new_sui_coin() {
let handler = CoinBalanceBuckets::default();
let mut builder = TestCheckpointDataBuilder::new(1);
builder = builder
.start_transaction(0)
.create_sui_object(0, 0)
.create_sui_object(1, 100)
.finish_transaction();
let checkpoint = builder.build_checkpoint();
let values = CoinBalanceBuckets.process(&Arc::new(checkpoint)).unwrap();
let values = handler.process(&Arc::new(checkpoint)).unwrap();
assert_eq!(values.len(), 2);
assert!(values.iter().any(|v| matches!(
v.change,
Expand All @@ -382,14 +383,15 @@ mod tests {

#[test]
fn test_process_coin_balance_buckets_new_other_coin() {
let handler = CoinBalanceBuckets::default();
let mut builder = TestCheckpointDataBuilder::new(1);
let coin_type = TypeTag::from_str("0x0::a::b").unwrap();
builder = builder
.start_transaction(0)
.create_coin_object(0, 0, 10, coin_type.clone())
.finish_transaction();
let checkpoint = builder.build_checkpoint();
let values = CoinBalanceBuckets.process(&Arc::new(checkpoint)).unwrap();
let values = handler.process(&Arc::new(checkpoint)).unwrap();
assert_eq!(values.len(), 1);
assert_eq!(
&values[0].change,
Expand All @@ -404,13 +406,14 @@ mod tests {

#[test]
fn test_process_coin_balance_buckets_balance_change() {
let handler = CoinBalanceBuckets::default();
let mut builder = TestCheckpointDataBuilder::new(1);
builder = builder
.start_transaction(0)
.create_sui_object(0, 10010)
.finish_transaction();
let checkpoint = builder.build_checkpoint();
let values = CoinBalanceBuckets.process(&Arc::new(checkpoint)).unwrap();
let values = handler.process(&Arc::new(checkpoint)).unwrap();
assert_eq!(values.len(), 1);
assert_eq!(
values[0].change,
Expand All @@ -429,7 +432,7 @@ mod tests {
.transfer_coin_balance(0, 1, 1, 10)
.finish_transaction();
let checkpoint = builder.build_checkpoint();
let values = CoinBalanceBuckets.process(&Arc::new(checkpoint)).unwrap();
let values = handler.process(&Arc::new(checkpoint)).unwrap();
assert_eq!(values.len(), 1);
assert_eq!(
values[0].change,
Expand All @@ -448,7 +451,7 @@ mod tests {
.transfer_coin_balance(0, 2, 1, 1)
.finish_transaction();
let checkpoint = builder.build_checkpoint();
let values = CoinBalanceBuckets.process(&Arc::new(checkpoint)).unwrap();
let values = handler.process(&Arc::new(checkpoint)).unwrap();
assert_eq!(values.len(), 2);
assert!(values.iter().any(|v| v.change
== CoinBalanceBucketChangeKind::Insert {
Expand All @@ -468,6 +471,7 @@ mod tests {

#[test]
fn test_process_coin_balance_buckets_coin_deleted() {
let handler = CoinBalanceBuckets::default();
let mut builder = TestCheckpointDataBuilder::new(1);
builder = builder
.start_transaction(0)
Expand All @@ -480,13 +484,14 @@ mod tests {
.delete_object(0)
.finish_transaction();
let checkpoint = builder.build_checkpoint();
let values = CoinBalanceBuckets.process(&Arc::new(checkpoint)).unwrap();
let values = handler.process(&Arc::new(checkpoint)).unwrap();
assert_eq!(values.len(), 1);
assert_eq!(values[0].change, CoinBalanceBucketChangeKind::Delete);
}

#[test]
fn test_process_coin_balance_buckets_owner_change() {
let handler = CoinBalanceBuckets::default();
let mut builder = TestCheckpointDataBuilder::new(1);
builder = builder
.start_transaction(0)
Expand All @@ -499,7 +504,7 @@ mod tests {
.transfer_object(0, 1)
.finish_transaction();
let checkpoint = builder.build_checkpoint();
let values = CoinBalanceBuckets.process(&Arc::new(checkpoint)).unwrap();
let values = handler.process(&Arc::new(checkpoint)).unwrap();
assert_eq!(values.len(), 1);
assert_eq!(
values[0].change,
Expand All @@ -514,6 +519,7 @@ mod tests {

#[test]
fn test_process_coin_balance_buckets_object_owned() {
let handler = CoinBalanceBuckets::default();
let mut builder = TestCheckpointDataBuilder::new(1);
builder = builder
.start_transaction(0)
Expand All @@ -528,7 +534,7 @@ mod tests {
.change_object_owner(0, Owner::ObjectOwner(dbg_addr(1)))
.finish_transaction();
let checkpoint = builder.build_checkpoint();
let values = CoinBalanceBuckets.process(&Arc::new(checkpoint)).unwrap();
let values = handler.process(&Arc::new(checkpoint)).unwrap();
assert_eq!(values.len(), 1);
assert_eq!(values[0].change, CoinBalanceBucketChangeKind::Delete);
}
Expand Down
109 changes: 0 additions & 109 deletions crates/sui-indexer-alt/src/handlers/coin_balance_buckets_pruner.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/sui-indexer-alt/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

pub(crate) mod coin_balance_buckets;
pub(crate) mod coin_balance_buckets_pruner;
pub(crate) mod ev_emit_mod;
pub(crate) mod ev_struct_inst;
pub(crate) mod kv_checkpoints;
Expand Down

0 comments on commit b632f95

Please sign in to comment.