Skip to content

Commit fd1977b

Browse files
authored
Create minimarket_tests.move
1 parent 86cb0e6 commit fd1977b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#[test_only]
2+
module minimarket::minimarket_tests {
3+
use 0x1::signer;
4+
use minimarket::minimarket;
5+
6+
// позитив: init → list → buy → withdraw_fees
7+
#[test(s = @0xC)]
8+
public entry fun test_list_buy_withdraw(s: &signer) {
9+
let a = signer::address_of(s);
10+
minimarket::init(s, 1000); // 10% комиссия
11+
minimarket::list(s, a, 0, 10_000); // новый лот
12+
minimarket::buy(s, a, 0, 10_000); // покупка
13+
minimarket::withdraw_fees(s, a); // админ = продавец
14+
let bal = minimarket::view_balance(a, a);
15+
assert!(bal == 10_000, 0);
16+
}
17+
18+
// негатив: повторный init должен падать (E_ALREADY_INITIALIZED = 1)
19+
#[test(admin = @0xD)]
20+
#[expected_failure(abort_code = 1, location = minimarket::minimarket)]
21+
public entry fun test_init_twice_fails(admin: &signer) {
22+
minimarket::init(admin, 250);
23+
minimarket::init(admin, 250);
24+
}
25+
}

0 commit comments

Comments
 (0)