|
@@ -5286,6 +5286,56 @@ fn create_dynamic_bag_with_objects_fails_with_unsufficient_balance() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+#[test]
|
|
|
+fn create_dynamic_bag_with_objects_fails_with_incoherent_accounts() {
|
|
|
+ build_test_externalities().execute_with(|| {
|
|
|
+ let starting_block = 1;
|
|
|
+ run_to_block(starting_block);
|
|
|
+
|
|
|
+ // set limit size 100 and limit obj number 20
|
|
|
+ set_max_voucher_limits_with_params(100, 20);
|
|
|
+ // create 3 buckets with size limit 10 and objects limit 3
|
|
|
+ create_storage_buckets_with_limits(3, 10, 3);
|
|
|
+
|
|
|
+ let dynamic_bag_id = DynamicBagId::<Test>::Member(DEFAULT_MEMBER_ID);
|
|
|
+
|
|
|
+ let deletion_prize_value = 100;
|
|
|
+ let deletion_prize_account_id = DEFAULT_MEMBER_ACCOUNT_ID;
|
|
|
+ let initial_balance = 100; // just enough for the del prize
|
|
|
+ increase_account_balance(&deletion_prize_account_id, initial_balance);
|
|
|
+
|
|
|
+ let deletion_prize = DynamicBagDeletionPrize::<Test> {
|
|
|
+ prize: deletion_prize_value,
|
|
|
+ account_id: deletion_prize_account_id,
|
|
|
+ };
|
|
|
+
|
|
|
+ // try uploading with > 0 objects exceeding balance
|
|
|
+ let data_objects = create_data_object_candidates(1, 3);
|
|
|
+ let upload_parameters = UploadParameters::<Test> {
|
|
|
+ bag_id: BagId::<Test>::from(dynamic_bag_id.clone()),
|
|
|
+ object_creation_list: data_objects.clone(),
|
|
|
+ deletion_prize_source_account_id: DEFAULT_MEMBER_ACCOUNT_ID + 1,
|
|
|
+ expected_data_size_fee: Storage::data_object_per_mega_byte_fee(),
|
|
|
+ };
|
|
|
+
|
|
|
+ // pre-check balances
|
|
|
+ assert_eq!(
|
|
|
+ Balances::usable_balance(&DEFAULT_MEMBER_ACCOUNT_ID),
|
|
|
+ initial_balance
|
|
|
+ );
|
|
|
+ assert_eq!(
|
|
|
+ Balances::usable_balance(&<StorageTreasury<Test>>::module_account_id()),
|
|
|
+ 0
|
|
|
+ );
|
|
|
+
|
|
|
+ CreateDynamicBagWithObjectsFixture::default()
|
|
|
+ .with_bag_id(dynamic_bag_id.clone())
|
|
|
+ .with_deletion_prize(deletion_prize.clone())
|
|
|
+ .with_objects(upload_parameters.clone())
|
|
|
+ .call_and_assert(Err(Error::<Test>::AccountsNotCoherent.into()));
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
#[test]
|
|
|
fn can_delete_dynamic_bags_with_objects_succeeded() {
|
|
|
build_test_externalities().execute_with(|| {
|