Skip to content

Conversation

gui1117
Copy link
Contributor

@gui1117 gui1117 commented Sep 10, 2025

I think the doc is wrong in regards to the spendable amount: the formula is wrong in some situations.
Also it says that reserved balances add a provider but the reality in the code is different:

#[test]
fn foo() {
	ExtBuilder::default().existential_deposit(10).build_and_execute_with(|| {
		let acc = 3456;
		Balances::set_balance(&acc, 100);
		Balances::set_balance(&2, 100);
		assert!(Balances::hold(&TestId::Foo, &acc, 10).is_ok());
		assert!(Balances::hold(&TestId::Foo, &acc, 90).is_err()); // No provider reference.
		assert!(Balances::hold(&TestId::Foo, &acc, 80).is_ok());
	});
}
#[test]
fn foo2() {
	ExtBuilder::default().existential_deposit(10).build_and_execute_with(|| {
		let acc = 3456;
		Balances::set_balance(&acc, 100);
		Balances::set_balance(&2, 100);
		System::inc_providers(&acc);
		assert!(Balances::hold(&TestId::Foo, &acc, 10).is_ok());
		assert!(Balances::hold(&TestId::Foo, &acc, 90).is_ok()); // Some provider reference.
	});
}

I have to look deeper to double check, but this is probably more correct than before.

@midegdugarova
Copy link
Contributor

thanks @gui1117 ! good catch

@gui1117
Copy link
Contributor Author

gui1117 commented Sep 22, 2025

don't merge as-is it was more a comment that a direct PR, I tried to improve the PR a bit, I am still not sure what is the exact spec, so I don't know what to write down.

Sometimes the account is dusted sometimes it is not. I couldn't find any consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants