Add transfer logic as post sync process step.
Add authtoken for youtuber in test data setup to call transfer api Update e2e test to include scenario where we transfer channel.
This commit is contained in:
parent
4cc0b71279
commit
d63aba568d
8 changed files with 82 additions and 9 deletions
|
@ -15,6 +15,9 @@ mysql -u lbry -plbry -D lbry -h "127.0.0.1" -P 15500 -e "$ASSIGNGROOP"
|
|||
#Add youtuber to sync
|
||||
ADDYTSYNCER='INSERT INTO user (given_name) VALUE("youtuber")'
|
||||
mysql -u lbry -plbry -D lbry -h "127.0.0.1" -P 15500 -e "$ADDYTSYNCER"
|
||||
#Insert an auth token for the youtuber to be used by ytsync
|
||||
ADDYTSYNCAUTHTOKEN='INSERT INTO auth_token (user_id, value) VALUE(2,"youtubertoken")'
|
||||
mysql -u lbry -plbry -D lbry -h "127.0.0.1" -P 15500 -e "$ADDYTSYNCAUTHTOKEN"
|
||||
#Add their youtube channel to be synced
|
||||
ADDYTCHANNEL="INSERT INTO youtube_data (user_id, status_token,desired_lbry_channel,channel_id,channel_name,status,created_at,source,total_videos,total_subscribers)
|
||||
VALUE(2,'3qzGyuVjQaf7t4pKKu2Er1NRW2LJkeWw','@beamertest','UCCyr5j8akeu9j4Q7urV0Lqw','BeamerAtLBRY','queued','2019-08-01 00:00:00','sync',1,0)"
|
||||
|
|
23
e2e/e2e.sh
23
e2e/e2e.sh
|
@ -50,16 +50,25 @@ echo "successfully started..."
|
|||
#Data Setup for test
|
||||
./data_setup.sh
|
||||
|
||||
# Execute the test!
|
||||
# Execute the sync test!
|
||||
./../bin/ytsync --channelID UCCyr5j8akeu9j4Q7urV0Lqw #Force channel intended...just in case. This channel lines up with the api container
|
||||
# Assert the status
|
||||
status=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT status FROM youtube_data WHERE id=1')
|
||||
videoStatus=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT status FROM synced_video WHERE id=1')
|
||||
if [[ $status != "synced" || $videoStatus != "published" ]]; then
|
||||
docker-compose logs --tail="all" lbrycrd
|
||||
docker-compose logs --tail="all" walletserver
|
||||
docker-compose logs --tail="all" lbrynet
|
||||
docker-compose logs --tail="all" internalapis
|
||||
# Reset status for tranfer test
|
||||
mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e "UPDATE youtube_data SET status = 'queued' WHERE id = 1"
|
||||
# Trigger transfer api
|
||||
echo "curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' http://localhost:15400/yt/transfer?auth_token=youtubertoken&address=n1Ygra2pyD6cpESv9GtPM9kDkr4bPeu1Dc"
|
||||
# Execute the transfer test!
|
||||
./../bin/ytsync --channelID UCCyr5j8akeu9j4Q7urV0Lqw #Force channel intended...just in case. This channel lines up with the api container
|
||||
transferStatus=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT transferred FROM youtube_data WHERE id=1')
|
||||
if [[ $status != "synced" || $videoStatus != "published" || transferStatus != "1" ]]; then
|
||||
echo "Channel Status: $status"
|
||||
echo "Video Status: $videoStatus"
|
||||
echo "Transfer Status: $transferStatus"
|
||||
#docker-compose logs --tail="all" lbrycrd
|
||||
#docker-compose logs --tail="all" walletserver
|
||||
#docker-compose logs --tail="all" lbrynet
|
||||
#docker-compose logs --tail="all" internalapis
|
||||
echo "List local /var/tmp"
|
||||
find /var/tmp
|
||||
exit 1; fi;
|
|
@ -4,5 +4,5 @@ if [ $# -eq 0 ]
|
|||
echo "No docker tag argument supplied. Use './build.sh <tag>'"
|
||||
exit 1
|
||||
fi
|
||||
docker build --tag lbry/lbrycrd:$1 .
|
||||
docker build --build-arg VERSION=$1 --tag lbry/lbrycrd:$1 .
|
||||
docker push lbry/lbrycrd:$1
|
|
@ -147,6 +147,8 @@ func (s *SyncManager) Start() error {
|
|||
AwsS3Bucket: s.awsS3Bucket,
|
||||
namer: namer.NewNamer(),
|
||||
Fee: channels[0].Fee,
|
||||
publishAddress: channels[0].PublishAddress,
|
||||
transferState: channels[0].TransferState,
|
||||
}
|
||||
shouldInterruptLoop = true
|
||||
} else {
|
||||
|
@ -189,6 +191,8 @@ func (s *SyncManager) Start() error {
|
|||
AwsS3Bucket: s.awsS3Bucket,
|
||||
namer: namer.NewNamer(),
|
||||
Fee: c.Fee,
|
||||
publishAddress: c.PublishAddress,
|
||||
transferState: c.TransferState,
|
||||
})
|
||||
if q != StatusFailed {
|
||||
continue queues
|
||||
|
|
|
@ -125,6 +125,9 @@ func (s *Sync) walletSetup() error {
|
|||
if s.claimAddress == "" {
|
||||
return errors.Err("found blank claim address")
|
||||
}
|
||||
if s.transferState > 0 && s.publishAddress != "" {
|
||||
s.claimAddress = s.publishAddress
|
||||
}
|
||||
|
||||
err = s.ensureEnoughUTXOs()
|
||||
if err != nil {
|
||||
|
|
41
manager/transfer.go
Normal file
41
manager/transfer.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package manager
|
||||
|
||||
import (
|
||||
"github.com/lbryio/lbry.go/extras/errors"
|
||||
"github.com/lbryio/lbry.go/extras/jsonrpc"
|
||||
"github.com/lbryio/lbry.go/extras/util"
|
||||
)
|
||||
|
||||
func TransferChannel(channel *Sync) error {
|
||||
//Transfer channel
|
||||
for _, video := range channel.syncedVideos {
|
||||
//Todo - Wait for prior sync to see that the publish is confirmed in lbrycrd?
|
||||
//Todo - We need to fix the ClaimSearch call in lbry.go for 38.5 lbrynet
|
||||
c, err := channel.daemon.ClaimSearch(nil, &video.ClaimID, nil, nil)
|
||||
if err != nil {
|
||||
errors.Err(err)
|
||||
}
|
||||
if len(c.Claims) == 0 {
|
||||
errors.Err("cannot transfer: no claim found for this video")
|
||||
} else if len(c.Claims) > 1 {
|
||||
errors.Err("cannot transfer: too many claims. claimID: %s", video.ClaimID)
|
||||
}
|
||||
|
||||
streamUpdateOptions := jsonrpc.StreamUpdateOptions{
|
||||
StreamCreateOptions: &jsonrpc.StreamCreateOptions{
|
||||
ClaimCreateOptions: jsonrpc.ClaimCreateOptions{ClaimAddress: &channel.publishAddress},
|
||||
},
|
||||
Bid: util.PtrToString("0.009"), // Todo - Dont hardcode
|
||||
}
|
||||
|
||||
_, err = channel.daemon.StreamUpdate(video.ClaimID, streamUpdateOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Todo - Post to remote db that video is transferred
|
||||
}
|
||||
|
||||
// Todo - Transfer Channel as last step and post back to remote db that channel is transferred.
|
||||
|
||||
return nil
|
||||
}
|
|
@ -88,6 +88,8 @@ type Sync struct {
|
|||
namer *namer.Namer
|
||||
walletMux *sync.RWMutex
|
||||
queue chan video
|
||||
transferState int
|
||||
publishAddress string
|
||||
}
|
||||
|
||||
func (s *Sync) AppendSyncedVideo(videoID string, published bool, failureReason string, claimName string, claimID string, metadataVersion int8, size int64) {
|
||||
|
@ -308,7 +310,16 @@ func (s *Sync) FullCycle() (e error) {
|
|||
return err
|
||||
}
|
||||
|
||||
return s.doSync()
|
||||
err = s.doSync()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if s.transferState == 1 && s.publishAddress != "" { // Channel needs transfer
|
||||
return TransferChannel(s)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteSyncFolder(videoDirectory string) {
|
||||
|
|
|
@ -45,6 +45,8 @@ type YoutubeChannel struct {
|
|||
DesiredChannelName string `json:"desired_channel_name"`
|
||||
Fee *Fee `json:"fee"`
|
||||
ChannelClaimID string `json:"channel_claim_id"`
|
||||
TransferState int `json:"transfer_state"`
|
||||
PublishAddress string `json:"publish_address"`
|
||||
}
|
||||
|
||||
func (a *APIConfig) FetchChannels(status string, cp *SyncProperties) ([]YoutubeChannel, error) {
|
||||
|
|
Loading…
Reference in a new issue