accounts: fix function names in doc

This commit is contained in:
Daniel Liu 2026-01-31 12:53:36 +08:00
parent cb97c48cb6
commit bd97496d83
13 changed files with 34 additions and 29 deletions

View file

@ -2084,8 +2084,8 @@ var bindTests = []struct {
}, },
} }
// Tests that packages generated by the binder can be successfully compiled and // TestBindings tests that packages generated by the binder can be successfully
// the requested tester run against it. // compiled and the requested tester run against it.
func TestBindings(t *testing.T) { func TestBindings(t *testing.T) {
t.Parallel() t.Parallel()
// Skip the test if no Go command can be found // Skip the test if no Go command can be found

View file

@ -186,9 +186,9 @@ func (cb *contractBinder) bindMethod(original abi.Method) error {
return nil return nil
} }
// normalize a set of arguments by stripping underscores, giving a generic name // normalizeArgs normalizes a set of arguments by stripping underscores,
// in the case where the arg name collides with a reserved Go keyword, and finally // giving a generic name in the case where the arg name collides with
// converting to camel-case. // a reserved Go keyword, and finally converting to camel-case.
func normalizeArgs(args abi.Arguments) abi.Arguments { func normalizeArgs(args abi.Arguments) abi.Arguments {
args = slices.Clone(args) args = slices.Clone(args)
used := make(map[string]bool) used := make(map[string]bool)

View file

@ -323,7 +323,8 @@ func TestNormalizeArgs(t *testing.T) {
} }
} }
// returns a "pretty diff" on two strings. Useful if the strings are large. // prettyDiff returns a "pretty diff" on two strings. Useful if the strings
// are large.
func prettyDiff(have, want string) string { func prettyDiff(have, want string) string {
if have == want { if have == want {
return "" return ""

View file

@ -225,7 +225,7 @@ var (
{{capitalise .Name}} {{if .Indexed}}{{bindtopictype .Type $structs}}{{else}}{{bindtype .Type $structs}}{{end}}; {{end}} {{capitalise .Name}} {{if .Indexed}}{{bindtopictype .Type $structs}}{{else}}{{bindtype .Type $structs}}{{end}}; {{end}}
} }
// ErrorID returns the hash of canonical representation of the error's signature. // {{$contract.Type}}{{.Normalized.Name}}ErrorID returns the hash of canonical representation of the error's signature.
// //
// Solidity: {{.Original.String}} // Solidity: {{.Original.String}}
func {{$contract.Type}}{{.Normalized.Name}}ErrorID() common.Hash { func {{$contract.Type}}{{.Normalized.Name}}ErrorID() common.Hash {

View file

@ -115,7 +115,7 @@ type CBadThing struct {
Arg4 bool Arg4 bool
} }
// ErrorID returns the hash of canonical representation of the error's signature. // CBadThingErrorID returns the hash of canonical representation of the error's signature.
// //
// Solidity: error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4) // Solidity: error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4)
func CBadThingErrorID() common.Hash { func CBadThingErrorID() common.Hash {
@ -142,7 +142,7 @@ type CBadThing2 struct {
Arg4 *big.Int Arg4 *big.Int
} }
// ErrorID returns the hash of canonical representation of the error's signature. // CBadThing2ErrorID returns the hash of canonical representation of the error's signature.
// //
// Solidity: error BadThing2(uint256 arg1, uint256 arg2, uint256 arg3, uint256 arg4) // Solidity: error BadThing2(uint256 arg1, uint256 arg2, uint256 arg3, uint256 arg4)
func CBadThing2ErrorID() common.Hash { func CBadThing2ErrorID() common.Hash {
@ -227,7 +227,7 @@ type C2BadThing struct {
Arg4 bool Arg4 bool
} }
// ErrorID returns the hash of canonical representation of the error's signature. // C2BadThingErrorID returns the hash of canonical representation of the error's signature.
// //
// Solidity: error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4) // Solidity: error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4)
func C2BadThingErrorID() common.Hash { func C2BadThingErrorID() common.Hash {

View file

@ -73,8 +73,8 @@ func makeTestDeployerWithNonceAssignment(backend simulated.Client) func(input, d
return bind.DeployerWithNonceAssignment(bind.NewKeyedTransactor(testKey, chainId), backend) return bind.DeployerWithNonceAssignment(bind.NewKeyedTransactor(testKey, chainId), backend)
} }
// test that deploying a contract with library dependencies works, // TestDeploymentLibraries tests that deploying a contract with library
// verifying by calling method on the deployed contract. // dependencies works, verifying by calling method on the deployed contract.
func TestDeploymentLibraries(t *testing.T) { func TestDeploymentLibraries(t *testing.T) {
bindBackend, err := testSetup() bindBackend, err := testSetup()
if err != nil { if err != nil {
@ -117,8 +117,8 @@ func TestDeploymentLibraries(t *testing.T) {
} }
} }
// Same as TestDeployment. However, stagger the deployments with overrides: // TestDeploymentWithOverrides is same as TestDeployment. However, stagger the
// first deploy the library deps and then the contract. // deployments with overrides: first deploy the library deps and then the contract.
func TestDeploymentWithOverrides(t *testing.T) { func TestDeploymentWithOverrides(t *testing.T) {
bindBackend, err := testSetup() bindBackend, err := testSetup()
if err != nil { if err != nil {
@ -185,7 +185,7 @@ func TestDeploymentWithOverrides(t *testing.T) {
} }
} }
// returns transaction auth to send a basic transaction from testAddr // defaultTxAuth returns transaction auth to send a basic tx from testAddr
func defaultTxAuth() *bind.TransactOpts { func defaultTxAuth() *bind.TransactOpts {
signer := types.LatestSigner(params.AllDevChainProtocolChanges) signer := types.LatestSigner(params.AllDevChainProtocolChanges)
opts := &bind.TransactOpts{ opts := &bind.TransactOpts{

View file

@ -29,7 +29,7 @@ import (
// the stringer interface to allow printing type details in the tests below. // the stringer interface to allow printing type details in the tests below.
type typeWithoutStringer Type type typeWithoutStringer Type
// Tests that all allowed types get recognized by the type parser. // TestTypeRegexp tests that all allowed types get recognized by the type parser.
func TestTypeRegexp(t *testing.T) { func TestTypeRegexp(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {

View file

@ -121,9 +121,11 @@ func readBool(word []byte) (bool, error) {
} }
} }
// A function type is simply the address with the function selection signature at the end. // readFunctionType enforces that standard by always presenting it as
// a 24-array (address + sig = 24 bytes)
// //
// readFunctionType enforces that standard by always presenting it as a 24-array (address + sig = 24 bytes) // A function type is simply the address with the function selection
// signature at the end.
func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) { func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
if t.T != FunctionTy { if t.T != FunctionTy {
return [24]byte{}, errors.New("abi: invalid type in call to make function type byte array") return [24]byte{}, errors.New("abi: invalid type in call to make function type byte array")

View file

@ -22,8 +22,8 @@ import (
"testing" "testing"
) )
// Tests that HD derivation paths can be correctly parsed into our internal binary // TestHDPathParsing tests that HD derivation paths can be correctly
// representation. // parsed into our internal binary representation.
func TestHDPathParsing(t *testing.T) { func TestHDPathParsing(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {

View file

@ -190,7 +190,7 @@ func TestOverrideUnlock(t *testing.T) {
} }
} }
// This test should fail under -race if signing races the expiration goroutine. // TestSignRace should fail under -race if signing races the expiration goroutine.
func TestSignRace(t *testing.T) { func TestSignRace(t *testing.T) {
t.Parallel() t.Parallel()
_, ks := tmpKeyStore(t) _, ks := tmpKeyStore(t)
@ -233,8 +233,8 @@ func waitForKsUpdating(t *testing.T, ks *KeyStore, wantStatus bool, maxTime time
return false return false
} }
// Tests that the wallet notifier loop starts and stops correctly based on the // TestWalletNotifierLifecycle tests that the wallet notifier loop starts and stops correctly
// addition and removal of wallet event subscriptions. // based on the addition and removal of wallet event subscriptions.
func TestWalletNotifierLifecycle(t *testing.T) { func TestWalletNotifierLifecycle(t *testing.T) {
t.Parallel() t.Parallel()
// Create a temporary keystore to test with // Create a temporary keystore to test with
@ -280,8 +280,8 @@ type walletEvent struct {
a accounts.Account a accounts.Account
} }
// Tests that wallet notifications and correctly fired when accounts are added // TestWalletNotifications tests that wallet notifications and correctly fired
// or deleted from the keystore. // when accounts are added or deleted from the keystore.
func TestWalletNotifications(t *testing.T) { func TestWalletNotifications(t *testing.T) {
t.Parallel() t.Parallel()
_, ks := tmpKeyStore(t) _, ks := tmpKeyStore(t)

View file

@ -28,7 +28,8 @@ const (
veryLightScryptP = 1 veryLightScryptP = 1
) )
// Tests that a json key file can be decrypted and encrypted in multiple rounds. // TestKeyEncryptDecrypt tests that a json key file can be decrypted
// and encrypted in multiple rounds.
func TestKeyEncryptDecrypt(t *testing.T) { func TestKeyEncryptDecrypt(t *testing.T) {
t.Parallel() t.Parallel()
keyjson, err := os.ReadFile("testdata/very-light-scrypt.json") keyjson, err := os.ReadFile("testdata/very-light-scrypt.json")

View file

@ -31,7 +31,8 @@ import (
"golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/pbkdf2"
) )
// creates a Key and stores that in the given KeyStore by decrypting a presale key JSON // importPreSaleKey imports a Key and stores that in the given KeyStore
// by decrypting a presale key JSON
func importPreSaleKey(keyStore keyStore, keyJSON []byte, password string) (accounts.Account, *Key, error) { func importPreSaleKey(keyStore keyStore, keyJSON []byte, password string) (accounts.Account, *Key, error) {
key, err := decryptPreSaleKey(keyJSON, password) key, err := decryptPreSaleKey(keyJSON, password)
if err != nil { if err != nil {
@ -131,7 +132,7 @@ func aesCBCDecrypt(key, cipherText, iv []byte) ([]byte, error) {
return plaintext, err return plaintext, err
} }
// From https://leanpub.com/gocrypto/read#leanpub-auto-block-cipher-modes // pkcs7Unpad is from https://leanpub.com/gocrypto/read#leanpub-auto-block-cipher-modes
func pkcs7Unpad(in []byte) []byte { func pkcs7Unpad(in []byte) []byte {
if len(in) == 0 { if len(in) == 0 {
return nil return nil

View file

@ -45,7 +45,7 @@ func newWatcher(ac *accountCache) *watcher {
// enabled returns false on systems not supported. // enabled returns false on systems not supported.
func (*watcher) enabled() bool { return true } func (*watcher) enabled() bool { return true }
// starts the watcher loop in the background. // start starts the watcher loop in the background.
// Start a watcher in the background if that's not already in progress. // Start a watcher in the background if that's not already in progress.
// The caller must hold w.ac.mu. // The caller must hold w.ac.mu.
func (w *watcher) start() { func (w *watcher) start() {