Skip to content

Commit 4cafd46

Browse files
authored
Update my_token_tests.move
1 parent 1e4f784 commit 4cafd46

1 file changed

Lines changed: 10 additions & 28 deletions

File tree

mytoken/tests/my_token_tests.move

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
#[test_only]
2-
module 0xb35962eed27b9a272d82673f2b7a99e7257b7b1a9af02c1a09143dacbaf498bd::my_token_tests {
3-
use 0x1::signer;
2+
module MyToken::my_token_tests {
43
use 0x1::vector;
5-
use 0xb35962eed27b9a272d82673f2b7a99e7257b7b1a9af02c1a09143dacbaf498bd::coin;
4+
use MyToken::coin;
65

7-
/// «Мусорка», чтобы не дропать Coin локально: складируем в вектор.
6+
// Простой «синк», чтобы не дропать ресурс coin::Coin
87
struct Trash has key { inner: vector<coin::Coin> }
98

10-
public entry fun init_trash(s: &signer) {
11-
move_to(s, Trash { inner: vector::empty<coin::Coin>() });
9+
public entry fun init_trash(acc: &signer) {
10+
move_to(acc, Trash { inner: vector::empty<coin::Coin>() });
1211
}
1312

14-
fun sink(s: &signer, c: coin::Coin) acquires Trash {
15-
let t = borrow_global_mut<Trash>(signer::address_of(s));
13+
fun sink(acc: &signer, c: coin::Coin) acquires Trash {
14+
let t = borrow_global_mut<Trash>(signer::address_of(acc));
1615
vector::push_back(&mut t.inner, c);
1716
}
1817

19-
// === Позитивы ===
20-
2118
#[test(admin = @0xA)]
2219
public entry fun test_mint_balance_ok(admin: &signer) acquires Trash {
2320
init_trash(admin);
@@ -26,22 +23,7 @@ module 0xb35962eed27b9a272d82673f2b7a99e7257b7b1a9af02c1a09143dacbaf498bd::my_to
2623
sink(admin, c);
2724
}
2825

29-
#[test(admin = @0xB)]
30-
public entry fun test_two_mints_sum_ok(admin: &signer) acquires Trash {
31-
init_trash(admin);
32-
let c1 = coin::mint(60);
33-
let c2 = coin::mint(40);
34-
let total = coin::balance(&c1) + coin::balance(&c2);
35-
assert!(total == 100, 1);
36-
sink(admin, c1);
37-
sink(admin, c2);
38-
}
39-
40-
// === Негатив ===
41-
// Без init_trash ресурса ещё нет — borrow_global_mut абортит.
42-
#[test(user = @0xC)]
43-
#[expected_failure]
44-
public entry fun test_borrow_without_init_fails(user: &signer) acquires Trash {
45-
let _t = borrow_global_mut<Trash>(signer::address_of(user));
46-
}
26+
// Негатив: попытка «borrow_global» там, где ресурса нет — падать не должно,
27+
// если модуль coin не хранит глобальное состояние. Этот тест чисто как шаблон:
28+
// можно удалить, если у coin нет такого поведения.
4729
}

0 commit comments

Comments
 (0)