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

[Neo Core Exception] Create WalletException and use it to replace all exceptions in wallet #3434

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Neo/Wallets/Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@

// Try Smart contract verification

var contract = NativeContract.ContractManagement.GetContract(context.Snapshot, scriptHash);
var contract = NativeContract.ContractManagement.GetContract(context.SnapshotCache, scriptHash);

Check warning on line 709 in src/Neo/Wallets/Wallet.cs

View workflow job for this annotation

GitHub Actions / Format

Fix formatting
Jim8y marked this conversation as resolved.
Show resolved Hide resolved
Jim8y marked this conversation as resolved.
Show resolved Hide resolved

if (contract != null)
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Neo.UnitTests/Network/P2P/Payloads/UT_Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public void FeeIsSignatureContract_TestScope_CurrentHash_NEO_FAULT()
// expects FAULT on execution of 'transfer' Application script
// due to lack of a valid witness validation
Transaction tx = null;
var exception = Assert.ThrowsException<WalletException>(() => tx = wallet.MakeTransaction(snapshot, script, acc.ScriptHash, signers));
var exception = Assert.ThrowsException<WalletException>(() => tx = wallet.MakeTransaction(snapshotCache, script, acc.ScriptHash, signers));
Assert.AreEqual(exception.ErrorType, WalletErrorType.ExecutionFault);
Assert.IsNull(tx);
}
Expand Down Expand Up @@ -710,7 +710,7 @@ public void FeeIsSignatureContract_TestScope_NoScopeFAULT()
// expects FAULT on execution of 'transfer' Application script
// due to lack of a valid witness validation
Transaction tx = null;
var exception = Assert.ThrowsException<WalletException>(() => tx = wallet.MakeTransaction(snapshot, script, acc.ScriptHash, signers, attributes));
var exception = Assert.ThrowsException<WalletException>(() => tx = wallet.MakeTransaction(snapshotCache, script, acc.ScriptHash, signers, attributes));
Assert.AreEqual(exception.ErrorType, WalletErrorType.ExecutionFault);
Assert.IsNull(tx);
}
Expand Down Expand Up @@ -761,7 +761,7 @@ public void FeeIsSignatureContract_UnexistingVerificationContractFAULT()
// expects ArgumentException on execution of 'CalculateNetworkFee' due to
// null witness_script (no account in the wallet, no corresponding witness
// and no verification contract for the signer)
var exception = Assert.ThrowsException<WalletException>(() => walletWithoutAcc.MakeTransaction(snapshot, script, acc.ScriptHash, signers));
var exception = Assert.ThrowsException<WalletException>(() => walletWithoutAcc.MakeTransaction(snapshotCache, script, acc.ScriptHash, signers));
Assert.AreEqual(exception.ErrorType, WalletErrorType.ContractNotFound);
Assert.IsNull(tx);
}
Expand Down Expand Up @@ -1017,7 +1017,7 @@ public void FeeIsSignatureContract_TestScope_FeeOnly_Default()
Scopes = WitnessScope.None
} };

var exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshot, script, acc.ScriptHash, signers));
var exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshotCache, script, acc.ScriptHash, signers));
Assert.AreEqual(exception.ErrorType, WalletErrorType.ExecutionFault);

// change to global scope
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.UnitTests/Wallets/UT_AssetDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class UT_AssetDescriptor
[TestMethod]
public void TestConstructorWithNonexistAssetId()
{
var snapshot = TestBlockchain.GetTestSnapshotCache();
var snapshotCache = TestBlockchain.GetTestSnapshotCache();
var exception = Assert.ThrowsException<WalletException>(() =>
{
var descriptor = new Neo.Wallets.AssetDescriptor(snapshot, TestProtocolSettings.Default, UInt160.Parse("01ff00ff00ff00ff00ff00ff00ff00ff00ff00a4"));
var descriptor = new Neo.Wallets.AssetDescriptor(snapshotCache, TestProtocolSettings.Default, UInt160.Parse("01ff00ff00ff00ff00ff00ff00ff00ff00ff00a4"));
});
Assert.AreEqual(exception.ErrorType, WalletErrorType.ContractNotFound);
}
Expand Down
9 changes: 4 additions & 5 deletions tests/Neo.UnitTests/Wallets/UT_Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void TestMakeTransaction1()
WalletAccount account = wallet.CreateAccount(contract, glkey.PrivateKey);
account.Lock = false;

var exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshot, new TransferOutput[]
var exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshotCache, new TransferOutput[]
{
new TransferOutput()
{
Expand All @@ -308,7 +308,7 @@ public void TestMakeTransaction1()
}, UInt160.Zero));
Assert.AreEqual(exception.ErrorType, WalletErrorType.InsufficientFunds);

exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshot, new TransferOutput[]
exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshotCache, new TransferOutput[]
{
new TransferOutput()
{
Expand All @@ -319,8 +319,7 @@ public void TestMakeTransaction1()
}
}, account.ScriptHash));
Assert.AreEqual(exception.ErrorType, WalletErrorType.InsufficientFunds);

exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshot, new TransferOutput[]
exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshotCache, new TransferOutput[]
{
new TransferOutput()
{
Expand Down Expand Up @@ -375,7 +374,7 @@ public void TestMakeTransaction2()
{
var snapshotCache = TestBlockchain.GetTestSnapshotCache();
MyWallet wallet = new();
var exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshot, Array.Empty<byte>(), null, null, Array.Empty<TransactionAttribute>()));
var exception = Assert.ThrowsException<WalletException>(() => wallet.MakeTransaction(snapshotCache, Array.Empty<byte>(), null, null, Array.Empty<TransactionAttribute>()));
Assert.AreEqual(exception.ErrorType, WalletErrorType.InsufficientFunds);

Contract contract = Contract.Create(new ContractParameterType[] { ContractParameterType.Boolean }, new byte[] { 1 });
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.