Testing Feather
Unit testsâ
To run all go unit tests *_test.go in the cli directory:
go test ./...
Integration testsâ
The main integration test is between Feather CLI and the Coordinator smart contract (currently deployed on pisco-1) which lives in the coordinator directory.
You must uncomment t.Skip() before running the test or the test is simply skipped. It prevents integration tests being run with unit tests during go test ./... (until a better way is found).
go test -run ^TestTerraClient$ github.com/terra-money/feather/internal/pkg/terra
E2E testsâ
Involves:
- Starting Feather daemon
- Starting the
autoapprover, which polls and approves chain join requests as they arrive - Publishing a chain (which Feather Daemon subscribes to)
- Signing
MsgDelegatetransactions that the chain deployer must do before chain launch with thefeather chaindeployer admincommand - Verifying the chain successfully on the Kubernetes Cluster
- Cleanup and deleting all Kubernetes resources
Running autoapproverâ
To use autoapprover, install Feather with the dev-facing commands:
make install-dev
Then, simply run:
feather start-autoapprover --key <key> --launch-id <launch_id>
Note that --key must be the same as the key used to create the launch --launch-id
Resetting persistent stateâ
To reset Feather to a clean slate, do the following:
- Delete feather launch configs:
rm -rf ~/.feather/launches - Delete k8s secrets:
kubectl -n feather get secretandkubectl -n feather delete secret ... - Delete k8s services:
kubectl -n feather get serviceandkubectl -n feather delete service ... - Delete k8s stateful sets:
kubectl -n feather get statefulsetandkubectl -n feather delete statefulset ... - Delete k8s persistent volume claims:
kubectl -n feather get persistentvolumeclaimandkubectl -n feather delete persistentvolumeclaim ... - Start feather daemon with the
--resetflag enabled (clears crash recovery checkpoints/action logs)
Mocking interfacesâ
It is recommended to use mockgen to generate mocks for interfaces.
- Install
mockgenaccording to https://github.com/uber-go/mock - Generate mock e.g.
internal/pkg/lcd/lcd_mock.go
# The working directory affects what source path is used in the generated filecd internal/pkg/lcdmockgen -source=./lcd.go -destination=./lcd_mock.go -package=lcd -typed