From bd97496d83e67f315c2d9281dbae466600421cf5 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Sat, 31 Jan 2026 12:53:36 +0800 Subject: [PATCH] accounts: fix function names in doc --- accounts/abi/abigen/bind_test.go | 4 ++-- accounts/abi/abigen/bindv2.go | 6 +++--- accounts/abi/abigen/bindv2_test.go | 3 ++- accounts/abi/abigen/source2.go.tpl | 2 +- .../bind/v2/internal/contracts/solc_errors/bindings.go | 6 +++--- accounts/abi/bind/v2/lib_test.go | 10 +++++----- accounts/abi/type_test.go | 2 +- accounts/abi/unpack.go | 6 ++++-- accounts/hd_test.go | 4 ++-- accounts/keystore/keystore_test.go | 10 +++++----- accounts/keystore/passphrase_test.go | 3 ++- accounts/keystore/presale.go | 5 +++-- accounts/keystore/watch.go | 2 +- 13 files changed, 34 insertions(+), 29 deletions(-) diff --git a/accounts/abi/abigen/bind_test.go b/accounts/abi/abigen/bind_test.go index 1651e637c8..a53237ed3b 100644 --- a/accounts/abi/abigen/bind_test.go +++ b/accounts/abi/abigen/bind_test.go @@ -2084,8 +2084,8 @@ var bindTests = []struct { }, } -// Tests that packages generated by the binder can be successfully compiled and -// the requested tester run against it. +// TestBindings tests that packages generated by the binder can be successfully +// compiled and the requested tester run against it. func TestBindings(t *testing.T) { t.Parallel() // Skip the test if no Go command can be found diff --git a/accounts/abi/abigen/bindv2.go b/accounts/abi/abigen/bindv2.go index ef4b769bb4..5a5eb70b78 100644 --- a/accounts/abi/abigen/bindv2.go +++ b/accounts/abi/abigen/bindv2.go @@ -186,9 +186,9 @@ func (cb *contractBinder) bindMethod(original abi.Method) error { return nil } -// normalize a set of arguments by stripping underscores, giving a generic name -// in the case where the arg name collides with a reserved Go keyword, and finally -// converting to camel-case. +// normalizeArgs normalizes a set of arguments by stripping underscores, +// giving a generic name in the case where the arg name collides with +// a reserved Go keyword, and finally converting to camel-case. func normalizeArgs(args abi.Arguments) abi.Arguments { args = slices.Clone(args) used := make(map[string]bool) diff --git a/accounts/abi/abigen/bindv2_test.go b/accounts/abi/abigen/bindv2_test.go index ee943f1c3f..830742adc5 100644 --- a/accounts/abi/abigen/bindv2_test.go +++ b/accounts/abi/abigen/bindv2_test.go @@ -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 { if have == want { return "" diff --git a/accounts/abi/abigen/source2.go.tpl b/accounts/abi/abigen/source2.go.tpl index 3d98cbb700..bdeb383098 100644 --- a/accounts/abi/abigen/source2.go.tpl +++ b/accounts/abi/abigen/source2.go.tpl @@ -225,7 +225,7 @@ var ( {{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}} func {{$contract.Type}}{{.Normalized.Name}}ErrorID() common.Hash { diff --git a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go index 627b86f1b9..cd8b69ca2a 100644 --- a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go @@ -115,7 +115,7 @@ type CBadThing struct { 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) func CBadThingErrorID() common.Hash { @@ -142,7 +142,7 @@ type CBadThing2 struct { 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) func CBadThing2ErrorID() common.Hash { @@ -227,7 +227,7 @@ type C2BadThing struct { 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) func C2BadThingErrorID() common.Hash { diff --git a/accounts/abi/bind/v2/lib_test.go b/accounts/abi/bind/v2/lib_test.go index 11360fc7dd..3018e4e1f8 100644 --- a/accounts/abi/bind/v2/lib_test.go +++ b/accounts/abi/bind/v2/lib_test.go @@ -73,8 +73,8 @@ func makeTestDeployerWithNonceAssignment(backend simulated.Client) func(input, d return bind.DeployerWithNonceAssignment(bind.NewKeyedTransactor(testKey, chainId), backend) } -// test that deploying a contract with library dependencies works, -// verifying by calling method on the deployed contract. +// TestDeploymentLibraries tests that deploying a contract with library +// dependencies works, verifying by calling method on the deployed contract. func TestDeploymentLibraries(t *testing.T) { bindBackend, err := testSetup() if err != nil { @@ -117,8 +117,8 @@ func TestDeploymentLibraries(t *testing.T) { } } -// Same as TestDeployment. However, stagger the deployments with overrides: -// first deploy the library deps and then the contract. +// TestDeploymentWithOverrides is same as TestDeployment. However, stagger the +// deployments with overrides: first deploy the library deps and then the contract. func TestDeploymentWithOverrides(t *testing.T) { bindBackend, err := testSetup() 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 { signer := types.LatestSigner(params.AllDevChainProtocolChanges) opts := &bind.TransactOpts{ diff --git a/accounts/abi/type_test.go b/accounts/abi/type_test.go index 95922548c4..660a430c67 100644 --- a/accounts/abi/type_test.go +++ b/accounts/abi/type_test.go @@ -29,7 +29,7 @@ import ( // the stringer interface to allow printing type details in the tests below. 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) { t.Parallel() tests := []struct { diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index 905b5ce629..8f4521956b 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -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) { if t.T != FunctionTy { return [24]byte{}, errors.New("abi: invalid type in call to make function type byte array") diff --git a/accounts/hd_test.go b/accounts/hd_test.go index 118ec5187b..af3bb1266a 100644 --- a/accounts/hd_test.go +++ b/accounts/hd_test.go @@ -22,8 +22,8 @@ import ( "testing" ) -// Tests that HD derivation paths can be correctly parsed into our internal binary -// representation. +// TestHDPathParsing tests that HD derivation paths can be correctly +// parsed into our internal binary representation. func TestHDPathParsing(t *testing.T) { t.Parallel() tests := []struct { diff --git a/accounts/keystore/keystore_test.go b/accounts/keystore/keystore_test.go index f8922a3f3f..a23806b680 100644 --- a/accounts/keystore/keystore_test.go +++ b/accounts/keystore/keystore_test.go @@ -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) { t.Parallel() _, ks := tmpKeyStore(t) @@ -233,8 +233,8 @@ func waitForKsUpdating(t *testing.T, ks *KeyStore, wantStatus bool, maxTime time return false } -// Tests that the wallet notifier loop starts and stops correctly based on the -// addition and removal of wallet event subscriptions. +// TestWalletNotifierLifecycle tests that the wallet notifier loop starts and stops correctly +// based on the addition and removal of wallet event subscriptions. func TestWalletNotifierLifecycle(t *testing.T) { t.Parallel() // Create a temporary keystore to test with @@ -280,8 +280,8 @@ type walletEvent struct { a accounts.Account } -// Tests that wallet notifications and correctly fired when accounts are added -// or deleted from the keystore. +// TestWalletNotifications tests that wallet notifications and correctly fired +// when accounts are added or deleted from the keystore. func TestWalletNotifications(t *testing.T) { t.Parallel() _, ks := tmpKeyStore(t) diff --git a/accounts/keystore/passphrase_test.go b/accounts/keystore/passphrase_test.go index 20ec0f5519..7b022efa47 100644 --- a/accounts/keystore/passphrase_test.go +++ b/accounts/keystore/passphrase_test.go @@ -28,7 +28,8 @@ const ( 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) { t.Parallel() keyjson, err := os.ReadFile("testdata/very-light-scrypt.json") diff --git a/accounts/keystore/presale.go b/accounts/keystore/presale.go index 6311e8d90a..98c2be2e8a 100644 --- a/accounts/keystore/presale.go +++ b/accounts/keystore/presale.go @@ -31,7 +31,8 @@ import ( "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) { key, err := decryptPreSaleKey(keyJSON, password) if err != nil { @@ -131,7 +132,7 @@ func aesCBCDecrypt(key, cipherText, iv []byte) ([]byte, error) { 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 { if len(in) == 0 { return nil diff --git a/accounts/keystore/watch.go b/accounts/keystore/watch.go index 1bef321cd1..246e7ce756 100644 --- a/accounts/keystore/watch.go +++ b/accounts/keystore/watch.go @@ -45,7 +45,7 @@ func newWatcher(ac *accountCache) *watcher { // enabled returns false on systems not supported. 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. // The caller must hold w.ac.mu. func (w *watcher) start() {