update ethereum tests

This accounts for the token name suffix and tests updating of wrapped asset meta

Change-Id: I752cd43e899df949d31e8f8ef7d706ead41f4502
This commit is contained in:
Hendrik Hofstadt 2021-09-01 14:13:18 +02:00
parent e6a51d0180
commit b0c95b85a6
1 changed files with 178 additions and 92 deletions

View File

@ -155,6 +155,7 @@ contract("Bridge", function () {
"TestToken", "TestToken",
"TT", "TT",
18, 18,
0,
accounts[0], accounts[0],
@ -240,8 +241,8 @@ contract("Bridge", function () {
// symbol (TT) // symbol (TT)
assert.equal(log.payload.substr(74, 64), "5454000000000000000000000000000000000000000000000000000000000000") assert.equal(log.payload.substr(74, 64), "5454000000000000000000000000000000000000000000000000000000000000")
// name (TestToken) // name (TestToken (Wormhole))
assert.equal(log.payload.substr(138, 64), "54657374546f6b656e0000000000000000000000000000000000000000000000") assert.equal(log.payload.substr(138, 64), "54657374546f6b656e2028576f726d686f6c6529000000000000000000000000")
}) })
it("should correctly deploy a wrapped asset for a token attestation", async function () { it("should correctly deploy a wrapped asset for a token attestation", async function () {
@ -290,7 +291,92 @@ contract("Bridge", function () {
assert.equal(symbol, "TT"); assert.equal(symbol, "TT");
const name = await initializedWrappedAsset.methods.name().call(); const name = await initializedWrappedAsset.methods.name().call();
assert.equal(name, "TestToken"); assert.equal(name, "TestToken (Wormhole)");
const decimals = await initializedWrappedAsset.methods.decimals().call();
assert.equal(decimals, 18);
const chainId = await initializedWrappedAsset.methods.chainId().call();
assert.equal(chainId, 1);
const nativeContract = await initializedWrappedAsset.methods.nativeContract().call();
assert.equal(nativeContract, "0x000000000000000000000000b7a2211e8165943192ad04f5dd21bedc29ff003e");
})
it("should correctly update a wrapped asset for a token attestation", async function () {
const initialized = new web3.eth.Contract(BridgeImplementationFullABI, TokenBridge.address);
const accounts = await web3.eth.getAccounts();
const data = "0x02" +
// tokenAddress
testBridgedAssetAddress +
// tokenchain
testBridgedAssetChain +
// decimals
"12" +
// symbol
"5555000000000000000000000000000000000000000000000000000000000000" +
// name
"5472656500000000000000000000000000000000000000000000000000000000";
let vm = await signAndEncodeVM(
0,
0,
testForeignChainId,
testForeignBridgeContract,
0,
data,
[
testSigner1PK
],
0,
0
);
let failed = false;
try {
await initialized.methods.updateWrapped("0x" + vm).send({
value: 0,
from: accounts[0],
gasLimit: 2000000
});
} catch (error) {
assert.equal(error.message, "Returned error: VM Exception while processing transaction: revert current metadata is up to date")
failed = true
}
assert.ok(failed)
vm = await signAndEncodeVM(
0,
0,
testForeignChainId,
testForeignBridgeContract,
1,
data,
[
testSigner1PK
],
0,
0
);
await initialized.methods.updateWrapped("0x" + vm).send({
value: 0,
from: accounts[0],
gasLimit: 2000000
});
const wrappedAddress = await initialized.methods.wrappedAsset("0x0001", "0x000000000000000000000000b7a2211e8165943192ad04f5dd21bedc29ff003e").call();
assert.ok(await initialized.methods.isWrappedAsset(wrappedAddress).call())
const initializedWrappedAsset = new web3.eth.Contract(TokenImplementation.abi, wrappedAddress);
const symbol = await initializedWrappedAsset.methods.symbol().call();
assert.equal(symbol, "UU");
const name = await initializedWrappedAsset.methods.name().call();
assert.equal(name, "Tree (Wormhole)");
const decimals = await initializedWrappedAsset.methods.decimals().call(); const decimals = await initializedWrappedAsset.methods.decimals().call();
assert.equal(decimals, 18); assert.equal(decimals, 18);