Also moved the mock definition to a separate file (mocks_test.go)
because it's gonna be used in other test files, and it didn't make sense
for it to stay inside chain_test.go.
CLI actions lack unit tests. I decided to use the approach similar to
what I found in `send_test.go` using gomock, but I don't rely on custom
"service" implementations but mock the whole FullNode API.
This first commit validates the test setup by testing the simplest method
of the chain category, e.g. `chain head`.
This requires a minor refactor of the CLI action code:
- The constructor (`GetFullNodeAPI`) checks if there's an injected mock
API in the app Metadata and uses that in unit tests.
- Actions shouldn't use raw `fmt.*` but instead write to the `app.Writer`
so the CLI output is testable
Use `color.NoColor` as a global progressively modified as one descends
down command flags. Allows non-surprising operation when --color is
accepted at multiple layers, and even makes this behave predictably:
lotus-miner --color actor control list --color=false
Lotus API endpoint are by default expressed as multiaddresses (i.e. lotus auth
api-info) which end in /http, although they can be provided as standard URLs too.
There is an inconsistency here because despite the "http" part, Lotus will use "ws" protocol.
This lets lotus default to "ws" but honor whatever the user puts in the multiaddress (i.e.
/dns4/my.lotus.node/tcp/443/https) would work now using https, where before it uses "ws".