Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UT random failure #3112

Closed
shargon opened this issue Feb 2, 2024 · 1 comment · Fixed by #3113
Closed

UT random failure #3112

shargon opened this issue Feb 2, 2024 · 1 comment · Fixed by #3113
Labels
Bug Used to tag confirmed bugs

Comments

@shargon
Copy link
Member

shargon commented Feb 2, 2024

Describe the bug
UT fail randomly, I think that it's because we Commit the snapshot in order to validate some tx, balance etc.

        [TestMethod]
        public void TestValidTransaction()
        {
            using var snapshot = TestBlockchain.TheNeoSystem.GetSnapshot();
            var walletA = TestUtils.GenerateTestWallet("123");
            var acc = walletA.CreateAccount();

            // Fake balance

            var key = new KeyBuilder(NativeContract.GAS.Id, 20).Add(acc.ScriptHash);
            var entry = snapshot.GetAndChange(key, () => new StorageItem(new AccountState()));
            entry.GetInteroperable<AccountState>().Balance = 100_000_000 * NativeContract.GAS.Factor;
            snapshot.Commit();

            // Make transaction

            var tx = CreateValidTx(snapshot, walletA, acc.ScriptHash, 0);

            senderProbe.Send(system.Blockchain, tx);
            senderProbe.ExpectMsg<Blockchain.RelayResult>(p => p.Result == VerifyResult.Succeed);

            senderProbe.Send(system.Blockchain, tx);
            senderProbe.ExpectMsg<Blockchain.RelayResult>(p => p.Result == VerifyResult.AlreadyInPool);
        }

To Reproduce
Steps to reproduce the behavior:

  1. Choose Neo.UnitTests.Ledger and Neo.UnitTests.SmartContract
  2. Run until failure

Expected behavior
UT's should work .

Screenshots
image

@shargon shargon added the Bug Used to tag confirmed bugs label Feb 2, 2024
@Jim8y
Copy link
Contributor

Jim8y commented Feb 2, 2024

we need mock snapshot

@shargon shargon mentioned this issue Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Used to tag confirmed bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants