hyperledger / fabric-sdk-go

https://wiki.hyperledger.org/display/fabric
Apache License 2.0
911 stars 508 forks source link

Supports loading of config values for Orderer.Endpoints #249

Open smallsixFight opened 1 year ago

smallsixFight commented 1 year ago

fabric version: release-2.2

configtx.yaml(release-2.2): configtx.yaml

sdk_config file : config_e2e.yaml without certificateAuthorities config

When I call the chaincode transaction using the code below, fabric-sdk-go returns 'orderers is nil'. I found out that this is due to the channel configuration of the application channel with Orderer.Endpoints but not OrdererAddresses, and the loadConfigValue function does not support "Endpoints" configuration loading.

func main() {
    sdk, err := fabsdk.New(config.FromFile("config_e2e.yaml"))
    if err != nil {
        log.Fatalln(err)
    }
    defer sdk.Close()
    cli, err := channel.New(sdk.ChannelContext("mychannel", fabsdk.WithUser("Admin"), fabsdk.WithOrg("Org1"),
    ))
    if err != nil {
        log.Fatalln(err)
    }
    resp, err := cli.Execute(channel.Request{
        ChaincodeID: "abstore",
        Fcn:         "init",
        Args:        [][]byte{[]byte("a"), []byte("100"), []byte("b"), []byte("200")},
        IsInit:      true,
    })
    if err != nil {
        log.Fatalln(err)
    }
    log.Println(string(resp.TransactionID))
}

Signed-off-by: smallsixFight smallsix.fight@gmail.com

codecov[bot] commented 1 year ago

Codecov Report

Merging #249 (09958cf) into main (7af45ce) will increase coverage by 0.04%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #249      +/-   ##
==========================================
+ Coverage   76.22%   76.26%   +0.04%     
==========================================
  Files         193      193              
  Lines       14103    14103              
==========================================
+ Hits        10750    10756       +6     
+ Misses       2385     2381       -4     
+ Partials      968      966       -2     
Impacted Files Coverage Δ
pkg/fab/chconfig/chconfig.go 68.51% <100.00%> (ø)
pkg/util/concurrent/lazycache/lazycache.go 94.17% <0.00%> (+5.82%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.