Prechádzať zdrojové kódy

Improve custom error helper when there is no match (#4437)

Francisco 2 rokov pred
rodič
commit
4bac6fa310
1 zmenil súbory, kde vykonal 3 pridanie a 6 odobranie
  1. 3 6
      test/helpers/customError.js

+ 3 - 6
test/helpers/customError.js

@@ -13,13 +13,10 @@ async function expectRevertCustomError(promise, expectedErrorName, args) {
       // VM Exception while processing transaction:
       // reverted with custom error 'InvalidAccountNonce("0x70997970C51812dc3A010C7d01b50e0d17dc79C8", 0)'
 
-      // We trim out anything inside the single quotes as comma-separated values
-      const [, error] = message.match(/'(.*)'/);
-
-      // Attempt to parse as an error
-      const match = error.match(/(?<name>\w+)\((?<args>.*)\)/);
+      // Attempt to parse as a custom error
+      const match = message.match(/custom error '(?<name>\w+)\((?<args>.*)\)'/);
       if (!match) {
-        expect.fail(`Couldn't parse "${error}" as a custom error`);
+        expect.fail(`Could not parse as custom error. ${message}`);
       }
       // Extract the error name and parameters
       const errorName = match.groups.name;