0

Follow these:

Running perigord deploy, enter "blah":

Enter passphrase for account 0x945Cd603A6754cB13C3D61d8fe240990f86f9f8A:
Enter passphrase for account 0x945Cd603A6754cB13C3D61d8fe240990f86f9f8A:
Error: [no contract code at given address]
exit status 1
Error: [exit status 1]

Running perigord test:

Running migration 1
Enter passphrase for account 0x945Cd603A6754cB13C3D61d8fe240990f86f9f8A:
----------------------------------------------------------------------
FAIL: tests/Foo.go:26: foo_test.TestFoo

tests/Foo.go:28:
    c.Assert(session, NotNil)
... value = nil

Running migration 1
Enter passphrase for account 0x945Cd603A6754cB13C3D61d8fe240990f86f9f8A:
----------------------------------------------------------------------
FAIL: tests/TokenERC20.go:19: TokenERC20Suite.SetUpTest

tests/TokenERC20.go:22:
    c.Fatal(err)
... Error: authentication needed: password or unlock


----------------------------------------------------------------------
PANIC: tests/TokenERC20.go:33: TokenERC20Suite.TestName

... Panic: Fixture has panicked (see related PANIC)
OOPS: 0 passed, 2 FAILED, 1 MISSED
--- FAIL: Test (0.01s)
FAIL
exit status 1
FAIL    github.com/quantonganh/tokendapp    0.065s
Error: [exit status 1]
exit status 1
Error: [exit status 1]

Sure, default account has been unlocked:

> web3.eth.coinbase
"0x945cd603a6754cb13c3d61d8fe240990f86f9f8a"
> personal.unlockAccount(web3.eth.coinbase, "blah", 0)
true

What is the problem? Is there any configuration where I can config the passphrase for coinbase account?


UPDATE Tue Apr 17 21:39:24 +07 2018

I added --unlock option to this line to unlock the accounts[0]:

geth --datadir $DIR --unlock 0x945Cd603A6754cB13C3D61d8fe240990f86f9f8A --password $DIR/etc/pw --nodiscover --maxpeers 0 --mine --minerthreads 1 --rpc --rpcapi "eth,web3,personal,net" console

In the console, I saw this:

INFO [04-17|21:38:22] Unlocked account                         address=0x945Cd603A6754cB13C3D61d8fe240990f86f9f8A
INFO [04-17|21:38:22] Etherbase automatically configured       address=0x945Cd603A6754cB13C3D61d8fe240990f86f9f8A

and to confirm:

> personal.listWallets
[{
    accounts: [{
        address: "0x945cd603a6754cb13c3d61d8fe240990f86f9f8a",
        url: "keystore:///tmp/geth_private_testnet/keystore/UTC--2017-12-13T18-58-05.147750439Z--945cd603a6754cb13c3d61d8fe240990f86f9f8a"
    }],
    status: "Unlocked",
    url: "keystore:///tmp/geth_private_testnet/keystore/UTC--2017-12-13T18-58-05.147750439Z--945cd603a6754cb13c3d61d8fe240990f86f9f8a"
}, {

but perigord test still asking me for passphrase, but the prompt does not appear to let me enter:

Running migration 1
Enter passphrase for account 0x945Cd603A6754cB13C3D61d8fe240990f86f9f8A:
----------------------------------------------------------------------
FAIL: tests/TokenERC20.go:19: TokenERC20Suite.SetUpTest

tests/TokenERC20.go:22:
    c.Fatal(err)
... Error: authentication needed: password or unlock

UPDATE Thu Apr 19 21:57:13 +07 2018

So, my question is why perigord test does not wait for an input (I have no chance to enter my passphrase "blah"). That is the reason for "authentication needed: password or unlock".

https://github.com/polyswarm/perigord/blob/59155a8da75c95698ac8949b5385e1e4da98702d/templates/test/test.go.tpl#L20 -->

https://github.com/polyswarm/perigord/blob/59155a8da75c95698ac8949b5385e1e4da98702d/testing/testing.go#L40 --> https://github.com/polyswarm/perigord/blob/59155a8da75c95698ac8949b5385e1e4da98702d/migration/migration.go#L115 -->

https://github.com/polyswarm/perigord/blob/59155a8da75c95698ac8949b5385e1e4da98702d/migration/migration.go#L86 -->

https://github.com/polyswarm/perigord/blob/59155a8da75c95698ac8949b5385e1e4da98702d/migration/migration.go#L33 -->

https://github.com/polyswarm/perigord/blob/59155a8da75c95698ac8949b5385e1e4da98702d/templates/migration/migration.go.tpl#L67 -->

https://github.com/polyswarm/perigord/blob/59155a8da75c95698ac8949b5385e1e4da98702d/templates/migration/migration.go.tpl#L19

5
  • @Downvoter: please leave a comment to let me know the reason.
    – quanta
    Apr 12 '18 at 2:23
  • Possibly web3.eth.accounts[0] is locked? Apr 17 '18 at 9:03
  • @LinmaoSong I've updated my question. You can see that 0x945cd603a6754cb13c3d61d8fe240990f86f9f8a is unlocked.
    – quanta
    Apr 17 '18 at 14:52
  • I wonder if this is a perigord bug. I seem to be able to reproduce. In my case, I attached to the test script's geth instance; and I was able to eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(100, "ether")}) without entering password. This means the unlock is successful on the geth side. Apr 19 '18 at 10:51
  • Correction to the above "bug" comment, it appears to be by design. See answer below. Apr 19 '18 at 12:28
1
+50

For the updated question

why "perigord test" doesn't take in password input from the terminal?

  • Apparently the "test command" is converted to "go test", see this line.
  • According to discussions here, go-lang unit tests have Stdin connected to /dev/null. This does make sense as unit tests are supposed to be automated.

I might be wrong as I am new to go-lang. It's probably best to discuss with Perigord dev.

For the original question

It seems this is expected. The key unlock status in Perigord appears to be unrelated to the key's status in the remote geth.

Perigord's migration script appears to be generated from a template source file. The template appears to always prompt for passwords, see this line here. The call to UnlockWithPrompot has no conditions like if unlocked. Thus, when the test runs the "migration" step, it always asks for a password.

Perigord's KeyStore appears to be a re-use of this package, which does its own parsing of keystone files (see function here). As a result, even if a key is unlocked inside geth, Perigord has no knowledge of it, as it doesn't rely on underling "web3" calls (unlikely Truffle Suit). Therefore, it has to ask for the password.

In conclusion, unlocking the key from geth has no effect on Perigord.

5
  • The problem is why perigord test does not wait for an input? I have no chance to enter my passphrase "blah". That is the reason for "authentication needed: password or unlock". I updated my question.
    – quanta
    Apr 19 '18 at 15:01
  • My suspicion is, in this line github.com/polyswarm/perigord/blob/… the terminal is taken over by the unit test framework. Apr 19 '18 at 15:14
  • As a result, even if a key is unlocked inside geth, Perigord has no knowledge of it, as it doesn't rely on underling "web3" calls (unlikely Truffle Suit) --> Do you mean that Truffle rely on underling "web3" calls --> it has knowledge of account status? If so, can Perigord be changed to act like Truffle?
    – quanta
    Apr 19 '18 at 15:58
  • Yes, Truffle relies on Javascript APIs - web3js.readthedocs.io/en/1.0 . In my opinion, the Perigord approach is better, despite it appears to be still in infancy. Apr 19 '18 at 16:00
  • See updated answer. Perigord probably shouldn't prompt for password in unit test mode, as the stdin is connected to /dev/null Apr 20 '18 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.