Получает ошибку аннотации ресурса при тестировании модуля libra - PullRequest
0 голосов
/ 10 октября 2019

Я экспериментирую с IR Libra Move и сталкиваюсь со следующей ошибкой при запуске cargo test -p functional_tests mod:

    [6] Error: VerificationFailure(
    [
        VMStatus {
            major_status: MISSING_ACQUIRES_RESOURCE_ANNOTATION_ERROR,
            sub_status: None,
            message: Some(
                "At offset 3 at index 2 while indexing function definition",
            ),
        },
    ],
)
-----------Status---------------
Failure
Error: Other("program failed at transaction 1, stage Verifier, no directives found, assuming failure")
thread 'functional_tests::modules/mod.mvir' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /home/chizisch/.cargo/registry/src/github.com-1ecc6299db9ec823/datatest-0.3.5/src/runner.rs:265:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.


failures:
    functional_tests::modules/mod.mvir

test result: FAILED. 10 passed; 1 failed; 0 ignored; 0 measured; 367 filtered out

thread 'main' panicked at 'Some tests failed', /home/ch/.cargo/registry/src/github.com-1ecc6299db9ec823/datatest-0.3.5/src/runner.rs:257:22

Мой код:

module mod {

    resource T {value: u64}

    public publish(){
        move_to_sender<T>(T{value:0});
        return;
    }


    public mint(value: u64): Self.T {
        return T{value: move(value)};
    }


    public balance(): u64{
        let sender: address;
        let token_ref: &mut Self.T;
        let token_value: u64;

        sender = get_txn_sender();  
        token_ref = borrow_global<T>(move(sender));
        token_value = *(&move(token_ref).value);

        return move(token_value);
    }
}

ПокаЯ не смог найти полезных ресурсов, чтобы понять, как работает Move IR. Я только просмотрел документацию Move и пару учебных пособий в сети. Если есть ресурс, чтобы понять, как работает семантика перемещения, это тоже будет приветствоваться.

...