From 577411cf5065fe862ca7dd3bb0f7fbb7a39a46a3 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 27 Aug 2019 19:49:51 +0200 Subject: [PATCH] fix e2e add support for supports (heh) --- e2e/e2e.sh | 10 ++++++---- manager/transfer.go | 17 +++++++++++++---- manager/ytsync.go | 8 ++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/e2e/e2e.sh b/e2e/e2e.sh index 060d277..560f856 100755 --- a/e2e/e2e.sh +++ b/e2e/e2e.sh @@ -54,11 +54,13 @@ echo "successfully started..." ./../bin/ytsync --channelID UCCyr5j8akeu9j4Q7urV0Lqw #Force channel intended...just in case. This channel lines up with the api container 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') -videoClaimID =$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT claim_id FROM synced_video WHERE id=1') +videoClaimID=$(mysql -u lbry -plbry -ss -D lbry -h "127.0.0.1" -P 15500 -e 'SELECT claim_id FROM synced_video WHERE id=1') # Create Supports for published claim -curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"supportclaim","params":["@BeamerTest","${videoClaimID}",1.0]}' -H 'content-type:text/plain;' --user lbry:lbry http://localhost:15200 -curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"supportclaim","params":["@BeamerTest","${videoClaimID}",2.0]}' -H 'content-type:text/plain;' --user lbry:lbry http://localhost:15200 -curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"supportclaim","params":["@BeamerTest","${videoClaimID}",3.0]}' -H 'content-type:text/plain;' --user lbry:lbry http://localhost:15200 +curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"supportclaim","params":["@BeamerTest","'${videoClaimID}'",1.0]}' -H 'content-type:text/plain;' --user lbry:lbry http://localhost:15200 +curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"supportclaim","params":["@BeamerTest","'${videoClaimID}'",2.0]}' -H 'content-type:text/plain;' --user lbry:lbry http://localhost:15200 +curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"supportclaim","params":["@BeamerTest","'${videoClaimID}'",3.0]}' -H 'content-type:text/plain;' --user lbry:lbry http://localhost:15200 +curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"supportclaim","params":["@BeamerTest","'${videoClaimID}'",3.0]}' -H 'content-type:text/plain;' --user lbry:lbry http://localhost:15200 +curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"generate","params":[1]}' -H 'content-type:text/plain;' --user lbry:lbry http://localhost:15200 # 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 diff --git a/manager/transfer.go b/manager/transfer.go index b230511..60a4d1a 100644 --- a/manager/transfer.go +++ b/manager/transfer.go @@ -44,14 +44,23 @@ func abandonSupports(s *Sync) error { allSupports = append(allSupports, (*supports).Items...) totalPages = (*supports).TotalPages } + alreadyAbandoned := make(map[string]bool, len(allSupports)) + for _, support := range allSupports { + _, ok := alreadyAbandoned[support.ClaimID] + if ok { + continue + } + alreadyAbandoned[support.ClaimID] = true + summary, err := s.daemon.SupportAbandon(&support.ClaimID, nil, nil, nil, nil) + if err != nil { + return errors.Err(err) + } + log.Infof("Abandoned support of %s (%s total output) LBC for claim %s", support.Amount, summary.Outputs[0].Amount, support.ClaimID) + } return nil } func transferVideos(s *Sync) error { - err := waitConfirmations(s) - if err != nil { - return err - } cleanTransfer := true for _, video := range s.syncedVideos { if !video.Published || video.Transferred || video.MetadataVersion != LatestMetadataVersion { diff --git a/manager/ytsync.go b/manager/ytsync.go index 980986a..8301daf 100644 --- a/manager/ytsync.go +++ b/manager/ytsync.go @@ -316,6 +316,14 @@ func (s *Sync) FullCycle() (e error) { } if s.shouldTransfer() { + err := waitConfirmations(s) + if err != nil { + return err + } + err = abandonSupports(s) + if err != nil { + return err + } err = transferVideos(s) if err != nil { return err