|
1 | 1 | #[test_only] |
2 | | -module 0xb35962eed27b9a272d82673f2b7a99e7257b7b1a9af02c1a09143dacbaf498bd::simple_nft_tests { |
3 | | - use 0xb35962eed27b9a272d82673f2b7a99e7257b7b1a9af02c1a09143dacbaf498bd::nft; |
| 2 | +module SimpleNFT::simple_nft_tests { |
| 3 | + use SimpleNFT::nft; |
4 | 4 |
|
5 | 5 | const A1: address = @0x1; |
6 | 6 | const A2: address = @0x2; |
7 | 7 |
|
| 8 | + // позитив: mint #0 → transfer → owner проверка |
8 | 9 | #[test] |
9 | 10 | public entry fun test_mint_transfer_ok() { |
10 | 11 | let r = nft::new_registry(); |
11 | | - |
12 | 12 | nft::mint(&mut r, A1, b"Test NFT"); |
13 | 13 | assert!(nft::get_owner(&r, 0) == A1, 0); |
14 | 14 |
|
15 | 15 | nft::transfer(&mut r, 0, A2); |
16 | 16 | assert!(nft::get_owner(&r, 0) == A2, 1); |
17 | 17 |
|
18 | | - nft::destroy_for_test(r); |
19 | | - } |
20 | | - |
21 | | - // Повторный mint должен падать с кодом 1 из SimpleNFT::nft::mint |
22 | | - #[test] |
23 | | - #[expected_failure(abort_code = 1, location = SimpleNFT::nft)] |
24 | | - public entry fun test_mint_twice_fails() { |
25 | | - let r = nft::new_registry(); |
26 | | - nft::mint(&mut r, A1, b"x"); |
27 | | - // второй mint -> abort(1) |
28 | | - nft::mint(&mut r, A1, b"y"); |
29 | | - // не дойдём, но чтобы удовлетворить типы: |
30 | | - nft::destroy_for_test(r); |
31 | | - } |
32 | | - |
33 | | - // Неверный id при transfer -> abort(3) в SimpleNFT::nft::transfer |
34 | | - #[test] |
35 | | - #[expected_failure(abort_code = 3, location = SimpleNFT::nft)] |
36 | | - public entry fun test_transfer_wrong_id_fails() { |
37 | | - let r = nft::new_registry(); |
38 | | - nft::mint(&mut r, A1, b"x"); |
39 | | - nft::transfer(&mut r, /*wrong*/ 999, A2); |
40 | | - nft::destroy_for_test(r); |
| 18 | + nft::destroy_registry_for_test(r); |
41 | 19 | } |
42 | 20 |
|
43 | | - // Неверный id при get_owner -> abort(5) в SimpleNFT::nft::get_owner |
| 21 | + // негатив: неверный id при get_owner → abort(5) в SimpleNFT::nft |
44 | 22 | #[test] |
45 | 23 | #[expected_failure(abort_code = 5, location = SimpleNFT::nft)] |
46 | 24 | public entry fun test_get_owner_wrong_id_fails() { |
47 | 25 | let r = nft::new_registry(); |
48 | 26 | nft::mint(&mut r, A1, b"x"); |
49 | 27 | let _ = nft::get_owner(&r, /*wrong*/ 123); |
50 | | - nft::destroy_for_test(r); |
| 28 | + nft::destroy_registry_for_test(r); |
51 | 29 | } |
52 | 30 | } |
0 commit comments